I have a test field in designer that is pulling its value from a tag. If the text field is selected (as if i were going to edit it) and the tag value changes the text field continues to show the old value. The old value is displayed in that text field until the value changes again. Is there a property that can be set so that when a text field is unselected it checks to see if the value has changed?
Well, I can speak for Igntion 7.9 since I’m not testing 8.0 yet but I don’t think IA changed this property ( correct me if i’m wrong ).
There is a property called Reject Updates During Edit ( it’s under the Behavior Group ) that allow the text field to change its value even during editing ( basically when it’s in focus ). By default is set to TRUE, you’ll have to set it to FALSE
Thanks, the problem is that I do want this behavior. If the text field is being edited I would like the updates to be rejected, but if the user does not change the value and clicks off of it I want the current value to be updated.
Then you want the ‘Commit on Focus Loss’ property.
@PGriffith this is not the behavior I am looking for. “Commit on Focus Loss” just writes whatever is in the text field when the focus is lost on that text field. My issue is that when I have focus on a text field and within designer I do not edit the field but the tag value the field is showing changes, when the focus is lost on the text field the value never changes to the current tag value.
It seems that when “Reject Updates During Edit” is true designer ignores the value change event that triggers the text field’s value to update. This is what I would expect. However when focus is lost on that text field I want that text field’s value to update to the current tag value.
Look at the “Defer Updates” checkbox.
@pturmel I am not editing the tag value from within the field. This is just behavior I noticed when a field just happens to be in focus. For example a user having mistakenly clicked in the field or they had gone to change the value then didn’t.
To simplify here is the events that trigger the behavior I am seeing
Text field is setup to display a tag value. Text field has “Reject Updates During Edit” set to true.
- User clicks into text field, text field is now in focus
- Tag value is changed externally, this is done through a connector module
- text field value stays the same since “Reject Updates During Edit” is true
- User clicks out of text field, text field is now out of focus
- text field continues to display old value
As a user I would expect once I click out of the text field without making any changes I have aborted that edit and the text field should go back to displaying the current value of the tag. If you happen to have a text field in focus during a value change that text field will continue to display outdated information until the next change of value.
So, what you’re asking for is just something that’s not supported by the way the client reacts to tag changes - clients don’t actively look for new values, and don’t store internal state of their previous values. So, if you have a text field, and you want to ensure that the value is correct when a user clicks out, then you can do so with an
onFocusLost component event script - just
system.tag.read() the tag value and write it to your component.
Consider using a custom property as an intermediary for your tag binding, plus a boolean custom property to hold a “resetNeeded” state. Then unidirectionally bind the entry field to the bound custom property. In a propertyChange event, monitor the value property with the follow logic:
- When new value equals the raw bound property value, you can assume it didn’t come from the operator – turn on resetNeeded.
- When different, this is the operator actually finishing an edit that needs to be written back – turn off resetNeeded and then copy this new value to the bound property (if bidirectionally bound) or perform whatever other scripted operation appropriate for a new value.
Then use an onFocusLost event to copy from the raw bound property to the entry field value, but only when resetNeeded is turned on.
This approach has zero gateway round-trip delays.
If you have the numeric/text field inside a template, the bound template property updates while field rejects updates during edit, so all you need in field
focusLost event is something like this (where
value is the template parameter bidirectionally bound to
floatValue inside template and to a tag outside template):
# Update display on focus lost in case a value update was rejected while focused.
event.source.floatValue = event.source.parent.value
The bidirectional bindings handle incoming tag changes as well as operator entries that need to be written back out to tag. The
focusLost code updates display with any tag value changes that were rejected by the field while focused due to