Hi,
I need to use the propertyChange event of a Numeric Text Field to do some special logging to the database. This special logging needs to be done only if it was the operator that changed the value by typing in the Numeric Text Field: nothing must be written to the db if the value changed due to the process status in the PLC.
Unfortunately I saw that the PropertyChange event is fired in either cases, i.e. when the operator input a new value by typing or when the PLC variable changes by itself.
Is there a way to differentiate the two events? My first thought was to set a boolean custom property like operatorChange in the keyTyped event, but this work only if the client uses a keyboard - in my case the client is a PC with touch-screen.
For these sorts of problems I move the tag binding to an extra custom property (bi-directional in your case or not as the situation requires), then uni-directionally bind the entry field’s editable property to the custom property.
In the propertyChange event for the editable field, you check the new value against the custom property. If it matches, the new value came from the binding. If different, the new value must have been operator input – then you can perform your custom logic, and in your case, including assigning the value back to the custom property.
I also recommend this technique when you have multiple items that need to change simultaneously – instead of writing back in the propertyChange event, perform the custom property assignments in a “Save” button’s actionPerformed event.