I have spinner increment set for numeric entry field component. Arrow up/down keys do not obey this increment. Is there a property I could set for the component? Alternatively, I have tried to configure an event on key press for the numeric entry field component, but don't understand the syntax:
def runAction(self, event):
if event.keyCode==38:
self.props.value = self.props.spinner.increment + self.props.value
Welcome to the Forum!
Please see Wiki - how to post code on this forum
I am not seeing this same issue.
What version of Ignition are you using?
Edit:
I didn't increment the actual spinner increment property in the prop tree. This indeed does not increase it.
Still post your JSON like @Transistor recommended as we should be able to help you from there.
Right-click on the component, Copy, and paste it in here. Then format it properly as code as shown in the linked article. Then we can see your settings and test it out.
1 Like
I hope I formatted the copy/paste correctly. I will also try to copy/paste the event I tried to script many different ways for which I really don't know the correct syntax. v8.1.47
[
{
"type": "ia.input.numeric-entry-field",
"version": 0,
"props": {
"format": "0,0",
"spinner": {
"increment": 100,
"keyboardEvent": "value"
},
"style": {
"borderBottomLeftRadius": 5,
"borderBottomRightRadius": 5,
"borderTopLeftRadius": 5,
"borderTopRightRadius": 5,
"fontSize": 25
}
},
"meta": {
"name": "NumericEntryField_W1FSP"
},
"position": {
"x": 9.35,
"y": 19.5,
"height": 39.2,
"width": 81
},
"custom": {},
"propConfig": {
"props.value": {
"binding": {
"config": {
"bidirectional": true,
"fallbackDelay": 2.5,
"mode": "direct",
"tagPath": "[TNC_Provider]WH1/WELL_1_FLOW_MODE_SP"
},
"type": "tag"
}
}
},
"events": {
"dom": {
"onKeyPress": {
"type": "script",
"scope": "G",
"config": {
"script": "\tif(event.keyCode==38, self.props.value = self.props.spinner.increment + self.props.value,)"
}
}
}
}
}
]`Preformatted text`
Please don't laugh, I am really just figuring this out as I go. This was one of many attempts at an keyboard event script configuraton to have the value (bi-directional tag binding) increase by the increment when the up arrow was pressed when this component was focused by clicking on it first. I tried many things trying to read some forum posts but was unsuccessful.
Event Scripts are written in Jython (Python Syntax)
Your script would need to look like this:
if(event.key==38):
self.props.value = self.props.spinner.increment + self.props.value
I did a little bit of playing around and I don't think what you want to do is going to be possible with the way this component is working.
I have a script that does exactly what you want increase by the increment, in this case 5, and when I hit the up arrow the script does write to the value
property, but the actual entry field still displays a value of 2. I imagine there is an internal mechansim on the numericEntryField
spinner that has the arrow keys increase it by 1.
When I click off of the entry box or hit enter and it is supposed to accept the value it reverts the value in the props tree to be the value actually in the field itself.
Right, restating the original problem for clarity:
- The Numerical Entry Field spinner is working. Pressing up or down increments / decrements by the value set in the `spinner.increment' property.
- The problem is that using the keyboard cursor up / down keys increments / decrements by 1.
- You want to script that to increment / decrement by the
spinner.increment
value. The problem appears to be that the component is intercepting the up / down keypress.
I saw the same effect as Benjamin. I think we're looking for some way to update the display (similar to a refreshBinding
). I haven't time to look at it now though.
Here's a script to play with:
def runAction(self, event):
step = self.props.spinner.increment
if event.keyCode == 38: # cursor up
system.perspective.print(self.props.value)
self.props.value += step
system.perspective.print(self.props.value)
return
if event.keyCode == 40: # cursor down
self.props.value -= step
1 Like
Thank you both! I will play around with this.
I played around with it some more and tried to do tricks like setFocus on another component and back on the numeric entry but no joy.
If you want more weirdness try setting mode : button
and the two numeric fields behave differently.
1 Like