Page 1 of 1

[1.1.61] Switch raises on_gui_click twice

Posted: Sat Jul 23, 2022 1:19 pm
by Mylon
Problem: On_gui_click event fires twice when a switch is toggled.

Expected: Event only fires once.

To recreate:

* Run this command to create a gui element and hook into the event:

Code: Select all

/c global.count = 0; game.player.gui.center.add{type="switch", name="bug"}; script.on_event(defines.events.on_gui_click, function() global.count = global.count +1 game.print(global.count) end)
* Click the toggle in the center of the screen.
* Observe results:
1
2

Expected:
1

I suspect this wasn't noticed because most people interacting with this were listening to the toggle event which works fine, but for most use cases this event should work as well.

Re: [1.1.61] Switch raises on_gui_click twice

Posted: Mon Mar 06, 2023 8:04 pm
by Rseding91
Thanks for the report. It's now fixed for the next release.