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 rejectUpdatesDuringEdit
.being set.