Page 1 of 1

when is this event called? events.on_gui_selection_state_changed

Posted: Sun Jan 21, 2024 6:49 pm
by tomdubliner
I have a little mod, with its GUI. On the GUI I have a drop-down list, and I'd like to do some actions whenever the user selects another item from the list.

I have registered a handler for the events.on_gui_selection_state_changed which I believe should be the event I need, but when debugging (I've placed a breakpoint in the function called by the trigger) nothing happens as if the event is not triggered.

example of the handler

Code: Select all

script.on_event(defines.events.on_gui_selection_state_changed, function(event)
game.print(event.element.name)
end)
The only event that gets triggered is when I click on the drop-down list (with event.on_gui_clik) but that only gets me the actual element in the list that is selected at the moment I've clicked, not the element that I'm changing to. I hope this makes sense.

Does any good soul know how this works or which event I can try out to get what I want (is it even possible?)

Re: when is this event called? events.on_gui_selection_state_changed

Posted: Sun Jan 21, 2024 8:51 pm
by Rseding91
Everything seems to work just fine when I test it.
factorio-run_SaPF8J1LRK.mp4
(2.5 MiB) Downloaded 17 times

Re: when is this event called? events.on_gui_selection_state_changed

Posted: Sun Jan 21, 2024 11:09 pm
by tomdubliner
Rseding91 wrote:
Sun Jan 21, 2024 8:51 pm
Everything seems to work just fine when I test it.
Thanks for taking the time to do this test. I have no idea what happened, but now that I got back to the code, without changing a single bit, it worked. :shock:
I ran it this afternoon before posting my distress call here, thousands of times, and wasn't working.

I guess Murphy's law is at play here. :twisted:

Thanks for your response nonetheless. :D