Eventchange for spinner

Is there any way of ‘Knowing’ whether the buttons are held down on or something so that I can call a script for the event?

Right now I have this:

if event.propertyName == "intValue": event.source.active = 1 else: event.source.active = 0
This is only writing a 0 for some reason whether I click the spinner or hold it down.
I think the solution is something I am missing on the Event handlers… or that the one I need has been removed from the component build…
I’m looking at the setup for this using python and java and it seems very simple but I can’t get it to work either way and I think this is the only piece i’m missing.

Using Ignition I have this on the property change script.
a timer is grouped with the spinner and I have my numeric step size bound to :

if({Root Container.Group.Spinner.level}<1,1,if({Root Container.Group.Spinner.level}<3,10,if({Root Container.Group.Spinner.level}<7,100,0)))
I need the Running property of the timer to be bound to a reset condition and a max bound value as well.

Something like this would be awesome…

if event.source == "MousePressed": event.source.active = 'true' else: event.source.active = 'false'

I think the best way to approach this may be a client timer script. You can put a custom property on each button, call it “upActive” or “downActive”, and have it set to 1 when the mousePressed event fires, and 0 when the mouseReleased event fires. The timer script will then check to see if the value is true, and execute whatever code needs to be executed, which in this case will either be incrementing or decrementing a component, such as a numeric text field.

How would I read a property on a button from a timer script?
How would I write back to a property?
Take advantage of the timer?

You can access the component of a window by getting a reference to the window, as outlined in the manual:

inductiveautomation.com/support/ … onents.htm

You’ll want to put the timer script inside of a try/except statement to suppress errors about the window not being open, because calling getWindow() depends on the window being open at that time. Also note that I said client timer script, a gateway timer script can’t access windows for a project.

The timer script is used to run a single increment/decrement, so instead of implementing a loop statement yourself, the script will increment/decrement at whatever interval you set the timer script to run. For example, I set the script to run every 100ms, so it will change the spinner every 100ms if I am holding the button down.

window = system.gui.getWindow(‘Screen’)
spinner = window.rootContainer.getComponent(“spinEdit”)
downActive = spinner.getPropertyValue(“downActive”)
upActive = spinner.getPropertyValue(“upActive”)
value = spinner.getPropertyValue(“value”)
increment = spinner.getPropertyValue(“increment”)
if upActive == 1:
incr = increment + 1
valuemod = value + incr
spinner.setPropertyValue(“increment”, incr)
spinner.getComponent(“Spinner”).floatValue = valuemod
#spinner.setPropertyValue(“value”, valuemod)

elif downActive == 1:
	incr = increment + 1
	valuemod = value - incr
	spinner.setPropertyValue("increment", incr)
	spinner.getComponent("Spinner").floatValue = valuemod
	spinner.setPropertyValue("increment", 0)	
	#need to handle bounds...

except ValueError:
# ignore error with a pass keyword

OK, this seems to work okay… I was thinking about incremementing like 10^0, 1, 2 to make it look better.

I have 2 concerns.
I noticed that on the numeric text box there is a suffix property and I would like a prefix instead…

Also, I set bounds enabled and I set my max and mins on the text box… For some reason these are completely ignored when this script affects it…although when I manually enter a value outside of that range it does not

I fixed the bounds directly in the value property change… It’s fine now, I was more concerned with how the text field allowed the change to happen.

You could use a numeric label and should be able to fix both those issues, but I’m guessing you need the user to type in a number in the box as well as use the up/down buttons, right?