I am doing a simple experiment on a Numeric Text Field :
if event.propertyName == "intValue":
print event.newValue
on propertyChange Event Handlers
but print nothing
I print event.propertyName but never shows the value "intValue".
shows "editValid".
If I change the code to
if event.propertyName == "editValid":
print event.newValue
only prints False or True but not the value.
Pls your help.
Is the numeric input field set to use integers? It can also be set to Long, Float, and Double, and if so, intValue
is not used.
I did
print event.propertyName
And show this values
formatterFactory
textFormatter
editValid
editValid
but never intValue
The numeric text field doesn't emit propertyChange events from the *Value
properties, for complicated internal Java Swing reasons.
And how I can access the value in Scripting?
Okay, I was wrong (but at least Phil was too
). Regardless of the mode, all four sub-property values are fired, as well as the non-visible value
property.
I tested with this script in the property change event:
print event.propertyName, '-', repr(event.newValue), '-', type(event.newValue)
And got this output from two value changes in preview mode in the designer:
value - 123 - <type 'int'>
intValue - 123 - <type 'int'>
longValue - 123L - <type 'long'>
floatValue - 123.0 - <type 'float'>
doubleValue - 123.0 - <type 'float'>
value - 1 - <type 'int'>
intValue - 1 - <type 'int'>
longValue - 1L - <type 'long'>
floatValue - 1.0 - <type 'float'>
doubleValue - 1.0 - <type 'float'>
So I don't know what's going on with your example.
2 Likes
Yeah, it happens.
/ Poking the guy with access to the source code. 
2 Likes
Thank you let me check what is wrong with my code, And I will post it here.
I did copy and paste on your code but the results arent the same:
editValid - True - <type 'bool'>
editValid - False - <type 'bool'>
editValid - True - <type 'bool'>
editValid - False - <type 'bool'>
editValid - True - <type 'bool'>
editValid - False - <type 'bool'>
editValid - True - <type 'bool'>
editValid - False - <type 'bool'>
editValid - True - <type 'bool'>
editValid - False - <type 'bool'>
editValid - True - <type 'bool'>
I don't know why . What place I can see what is wrong with my Designer?
If you leave the script in place and launch an actual client, what does it log in its own diagnostic console?
With this code:
print("event: " + str(event))
print("source: " + str(event.source))
print("newValue : " + str(event.newValue))
print("oldValue : " + str(event.oldValue))
print("propertyName : " + str(event.propertyName))
I am getting this results:
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=value; oldValue=123; newValue=1; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : 1
oldValue : 123
propertyName : value
event: java.beans.PropertyChangeEvent[propertyName=intValue; oldValue=123; newValue=1; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : 1
oldValue : 123
propertyName : intValue
event: java.beans.PropertyChangeEvent[propertyName=longValue; oldValue=123; newValue=1; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : 1
oldValue : 123
propertyName : longValue
event: java.beans.PropertyChangeEvent[propertyName=floatValue; oldValue=123.0; newValue=1.0; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : 1.0
oldValue : 123.0
propertyName : floatValue
event: java.beans.PropertyChangeEvent[propertyName=doubleValue; oldValue=123.0; newValue=1.0; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : 1.0
oldValue : 123.0
propertyName : doubleValue
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
Sometime works getting the values changes and others don't . I don't know why.
What if you create a brand new numeric text field and put the same script on it?
What if you set the property filter to 'All' and change the value of the 'Defer Updates' boolean property?
This is a brand new Numeric Text Field:
event: java.beans.PropertyChangeEvent[propertyName=formatterFactory; oldValue=com.inductiveautomation.factorypmi.application.components.PMINumericTextField$FormatterFactory@315d6377; newValue=com.inductiveautomation.factorypmi.application.components.PMINumericTextField$FormatterFactory@3ab73d89; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : com.inductiveautomation.factorypmi.application.components.PMINumericTextField$FormatterFactory@3ab73d89
oldValue : com.inductiveautomation.factorypmi.application.components.PMINumericTextField$FormatterFactory@315d6377
propertyName : formatterFactory
event: java.beans.PropertyChangeEvent[propertyName=textFormatter; oldValue=com.inductiveautomation.factorypmi.application.components.PMINumericTextField$DecimalNumberFormatter@21990af7; newValue=com.inductiveautomation.factorypmi.application.components.PMINumericTextField$DecimalNumberFormatter@20355414; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : com.inductiveautomation.factorypmi.application.components.PMINumericTextField$DecimalNumberFormatter@20355414
oldValue : com.inductiveautomation.factorypmi.application.components.PMINumericTextField$DecimalNumberFormatter@21990af7
propertyName : textFormatter
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=true; newValue=false; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : False
oldValue : True
propertyName : editValid
event: java.beans.PropertyChangeEvent[propertyName=editValid; oldValue=false; newValue=true; propagationId=null; source=PMINumericTextField[Numeric Text Field]]
source: PMINumericTextField[Numeric Text Field]
newValue : True
oldValue : False
propertyName : editValid
I am figuring out how to do the "What if you set the property filter to 'All' and change the value of the 'Defer Updates' boolean property?" part.
Sorry for the question
How do this?
@leonardo.godoi and @PGriffith Thank you now works . I learn a lot .