Page 1 of 1

[0.16.1] Checkboxes not raising `on_gui_click`

Posted: Thu Dec 14, 2017 9:23 am
by Narc
I'm using some checkboxes in my mod GUIs, and was relying on the documented (ctrl+F "checkbox") behaviour that they would raise `on_gui_click` when clicked -- this simplifies my GUI handling by using the same code for both buttons and checkboxes.

But now I see that checkboxes only raise `on_gui_checked_state_changed` anymore, so I have to handle both separately (luckily, they're sufficiently similar that I can ram them down the same path anyway).

Question is, is this an intended change (do the docs need updating?) or a mistake (will Factorio change again)?

Re: Checkboxes not raising `on_gui_click`

Posted: Thu Dec 14, 2017 11:23 am
by Aidiakapi
Strange that the docs say this. I've done a lot of GUI stuff in latest 0.15, and checkboxes definitely did not fire the on_click event. I think it's a mistake to make two events input events fire for one action though.

If your code can handle it fine, you can just use the same function as event handlers for both:

Code: Select all

local function handler()... end
script.on_event(defines..., handler) -- for each event

Re: Checkboxes not raising `on_gui_click`

Posted: Thu Dec 14, 2017 11:32 am
by Loewchen
What version is this about?

Re: Checkboxes not raising `on_gui_click`

Posted: Thu Dec 14, 2017 11:43 am
by Narc
Loewchen wrote:What version is this about?
Erp! Sorry, it's for 0.16.1. Edited the title, thanks for the reminder.
Aidiakapi wrote:Strange that the docs say this. I've done a lot of GUI stuff in latest 0.15, and checkboxes definitely did not fire the on_click event.[...]
Well, EvoGUI has always relied on just on_gui_click, but the change could easily originate in some later 0.15 -- I had 0.15.32 as my last played, and I'm not sure if I even used the checkboxes in that one so it could be even older.
Aidiakapi wrote:If your code can handle it fine, you can just use the same function as event handlers for both:
Yes, that's what I meant by
Narc wrote:(luckily, they're sufficiently similar that I can ram them down the same path anyway)
in the original post.

Re: [0.16.1] Checkboxes not raising `on_gui_click`

Posted: Thu Dec 14, 2017 12:17 pm
by Bilka
Duplicate: 54678

Re: [0.16.1] Checkboxes not raising `on_gui_click`

Posted: Thu Dec 14, 2017 12:27 pm
by Narc
So it is, good find! I did try a search, but apparently with the wrong terms. Glad to know this is intended behaviour, then.