How to update my code, that a click on a UI button ( "button clicked: Button" ) is detected immediately, and not just by the 2nd. click?

How to update my code, that a click on a UI button ( "button clicked: Button" ) is detected immediately, and not just by the 2nd. click?

I followed a simple training video how to build a UI button.

Sourcecode:

Instructions:

  1. Please fork this project and load it into your CORE IDE.
  2. In your CORE IDE, open the "Event log" window.
  3. Move your cursor on the white star and cklick several times.

Question:
1 Why must I press the button twice on the star, to get the message

"button clicked: Button"

instead of that this message already appears the FIRST time?

  1. How to fix the code, so that the message appears for the FIRST time I click on the star.

--

Update:
I added UI.SetCanCursorInteractWithUI(true)” at the start of the script, but kept it as comment.

  • If “UI.SetCanCursorInteractWithUI(true)” ⇒ “button clicked: Button” immediately detected by the first mouse click.
  • If “UI.SetCanCursorInteractWithUI(false)”, the default setting ⇒ “button clicked: Button” is detected by the 2nd. mouseclick.

Any further explaination would be great!

SIncerely
Rolf