Button + and - to write tag like spinner component

Hi everyone,

I want to add 2 buttons to raise and lower a tag (motor speed set point). My script actually adding one every time I press the button, but I want a function as the spinner to increase when am hold the + or - button.

Script button + for now is on mousePressed:
if event.source.Value != event.source.EngHigh:
event.source.Value += 1

Script button - for now is on mousePressed:
if event.source.Value != event.source.EngHigh:
event.source.Value -= 1

Best regard,
Gabriel

AFAIK there is no event that is fired while a mouse button is being held down. The events only fire once, so I’m not sure this functionality is entirely possible in the way you have envisioned it.

You may be able to use some mouse motion events to accomplish something similar that seems a bit complicated though.

I would probably just give them the ability to enter the number they wanted from the keyboard or perhaps multiple buttons for fine and coarse increments.

I accomplished this recently by using the timer component and having a pair of momentary buttons turn it on while they were pressed. Then, using a property change script, whenever the timer ticked I would adjust the value based on which button was pressed.

This approach avoided any while loops, and potentially any gui thread locking while adjusting setpoints.

I can provide some more detail if needed, but hopefully this can get you started.