newbie question, how to add security confirmation in button that bind to UDT parameter (boolean)?
so, i have 2 momentary button that handle Open and Close, i use UDT parameter for this button. im bit confuse how to add security confirmation on this button, coz i only find the security confirmation on the scripting properties.
There should be a security tab on the property editor window that you can change security on each component by role. Is this what you’re talking about?
tagpath = 'Path to UDT'
if system.gui.confirm(u'Are you sure?', 'Confirm'):
value = event.source.close
system.tag.writeToTag(tagpath + '/CLOSE', value)
Can you go into your MousePressed Property and select Script Editor and show what has been generated there? That should show when the write is happening.
Actually there is two problem when using confirmation dialog, first, the value changed before i click yes.
second, when i use this function in momentary button, the value stay at 1 after you click yes or no, momentary button should back to 0.
There are two actions happening when you click the momentary button. The button automatically sets its Control Value property to the On Value for the required amount of time and then resets it. That is what the momentary button is supposed to do and you can’t really stop this from happening.
The button is also going to run your mouse click event script. Your script is separate from the momentary action of the button. Your script asks for confirmation (not the default action of the button), and your script will write a value to the specified property (not the default action of the button). Your script has no instructions to reset the value.
If you don’t have anything bound to the button’s control value, then don’t worry about what that is doing. In your script you are modifying a property of a UDT type. Focus on making that set and then reset. I used the following script still on the button’s click event to achieve what I think you are after:
[code]if system.gui.confirm(u’Are you sure?’, ‘Confirm’):
event.source.parent.MOV.CLOSE = 1
def reset():
import system
event.source.parent.MOV.CLOSE = 0
system.util.invokeLater(reset, 5000)