britzl / defold-input

Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
MIT License
111 stars 26 forks source link

Button callback executes three times #1

Closed abigpotostew closed 6 years ago

abigpotostew commented 6 years ago

The callback to button.register gets executed three times per click release. I'm not sure if there's a phase to the button callback? Such as click, hold, release. But it's not clear to me why this happens. Reproduction: In any of your examples with a button, add a static print statement-- such as in savefile.gui_script inside add a print statement after line #9:

button.register("load/button", function() --line #9
    print("load") --added print
britzl commented 6 years ago

The examples you've tested from Ludobits did use the wrong inout bindings file. It used the all.input_bindings file with multiple bindings for left mouse button, which was the reason for seeing multiple callbacks. I've updated the Ludobits repo. Please give the new version of those examples a try or test the examples in this repo to verify that button callbacks work as intended. Re-ropen if you still have problems with buttons.