SpinBox event

I am creating a widget with a spinbox. On the event construct event I am loading the value for the Spinbox, which works fine:
Capture_1.PNG
The next step is to write to the variable (same as the loading variable) when the user is changing the value of the SpinBox either with the slider or when the value is committed over the text box.
I am trying to use the available events of the SpinBox “On Value Changed” and/or “On Value Committed”. However when I run my code and the widget is opening, the value of the SpinBox is always 0.


I am really confused and any help is much appreciated!

Hm weird, have you used breakpoints to check the code is actually being called?

Yes I just did that, I think the problem is when I open the widget. Because then the SpinBox event “On Value changed” is already triggered and sets the value to 0. But how do I fix that?

I solved it using a Boolean that is set to true as default and changed to false when the “Event construct” and all values are loaded. In the functions that act on the “On value changed” event I added a branch and the value is only changed when the Boolean is false. Ofc when I am leaving the widget, I set the Boolean to true again so it works when the user opens the widget multiple times. In that way I present that the value is set to 0. Below you can see the blueprints:

  1. Boolean “Widget Opening” is set to false at the end of the “Event construct” event.
  2. Functions that are called by the “On value changed” event, will only be executed when Boolean “Widget Opening” is false.
  3. Before “leaving” the widget, the Boolean “Widget Opening” is set to true again, to enable the user to open the widget multiple time.

I hope if someone else has that issue this will help.

Stay safe everyone,
Regards