Add more security layer to input component like numeric text field or text fiel

I am curious about more security levels on the input component

we have numeric text field and text field, spinner …that interacts with the operation

it could be a good idea if we can add confirmation before any change on those component

like a confirmation that asks(( are you sure you want to change this?))

any idea ?

As a property change event for a text input label something like -

if event.propertyName == 'text':
    if system.gui.confirm("Are you sure you want to change this?"):
        event.source.text = event.newValue
        event.source.text = event.oldValue
1 Like

Would that not change the property first, then wait for the yes/no and change it back if no?

1 Like

As long as Defer Updates is true on the text label this should work fine and will run when the user hits enter/exits the text label. If the person says yes they are sure then the event.source.text will be assigned the new value, otherwise it will revert.

This method will not work nicely if Defer Updates is false, it will run every time a new character is entered.

1 Like

Thanks for the replay

but another member told me (( propertyChange events happen after the property has already changed. You could add a custom property with the ‘real’ value, that you only write from scripting after your write has been attempted from the text component itself.))

what do you think ?

1 Like

As I understand it with text inputs, if defer updates are on, when the user signifies they are done typing, then the property change runs. So yes it will stay as the new text person wrote unless they decline the confirmation message, hence the need to revert with else: event.source.text = event.oldValue.

Another idea:
Leave the text inputs disabled. Put a button on the side. Have the button call system.gui.inputBox to get the users desired new text, use system.gui.confirm to get confirmation, and from there write the text from your inputBox to the text label or whatever component. Never let the person write directly into the text input box if you are concerned about property changes.

1 Like

Yes, bind your tag to a custom property, then uni-directionally bind the editable property from the custom property. I usually also style the input component so it is obvious when the two properties are different. Use a separate “save” button to finish the write. This approach also allows the operator to make multiple changes that get applied together.

1 Like

I use numeric text for an indirect tag to UDT parameter, how to apply your method, I already bind it to another property

if you check the 2-state toggle and multi-state button or one shot you will find this feature is built-in

I am looking for some this like this for other input componentsconfrim

You would have to build it yourself. Those features are only on those components. Or follow the design pattern laid out - using a Write button to do your confirmation window and write logic.

1 Like