Hello, I'm wondering if it's possible to have a "confirm click" pop-up with the button component in vision? I see it for the 2-state toggle but not the button.. Thanks!
I believe you'll need to use the one-shot button for confirmation. If that doesn't work for you, you'll have to script your own.
By confirmation I mean a pop up window to the user in the HMI that says "are you sure?" or similar after they click the button. Which is different from the one-shot button.
Yes, the one-shot has that capability, but the one-shot will write a single value (like 1) to the value when clicked and optionally confirmed via an "are you sure?" message.
How do you expect a momentary button to work? Momentary meaning a 1 is written when pressed, then a 0 when released. What happens when the dialog box pops up? The user must release their mouse button to click the confirm button. So that's probably why there's no option for this.
Hmmm. I thought one shot waits for the PLC to reset the variable, no? I don't want to do that
Yes, but how do you expect a momentary button to work? Are you wanting the HMI to send a 1, wait a bit, then write a 0 after confirming?
If you use a 1-shot button with the PLC resetting the 1 back to a 0, it will be more reliable than a momentary button. If you don't have control of the PLC code to make this possible, then you'll have to script your own where you can use the 1-shot button, but script it so that after a delay it writes a 0 back (don't use a timer). Use system.util.invokeLater
with a function and a delay on the actionPerformed event handler.
Do this, change to the script editor and check the value of your tag before requiring confirmation and writing the value.
#read custom property bidirectionally bound to tag
currentTagValue = event.source.tag
#button is on, turn it off
if currentValue:
event.source.tag = 0
#button is off, confirm and then turn on
else:
if system.gui.confirm(u'Are you sure?', 'Confirm'):
event.source.tag = 1
This is still working like a 1-shot though. It only writes a single value. They're wanting a 1, wait, then 0 like a momentary.
What @ryan.white linked would work too, but isn't a dialog confirmation, but more of an "arm the momentary button" toggle that enables the momentary button.
It doesn't need to be a momentary button. I want a variable to be set to true but only after the user confirms they want that to happen and it wasn't clicked by accident. I feel like there has to be a simpler way of doing this with the "button" component.
Not sure where the momentary requirement came from
If it's only being set to true and not back to false, then the 1-shot button or the simple require confirmation that @amarks posted will work.
Oh, I think I mis-read the orignal post.....asking about a button and I interpreted it as momenary button.
Really, a one-shot button is no different than the standard button component. I'm honestly not sure why both exist...
I guess with the one-shot button you get to skip the scripting dialog box
I believe the one-shot button waits for the PLC to reset it back to 0 before enabling it again. And also can change the text while the tag is written to another message.
The standard button does not set it back to 0 either. I do see the difference now. I haven't used a one-shot button before.
You could easily make the one-shot button component from a standard button component, 2 custom properties, and a style customizer. I see now
No, but the button becomes disabled and displays a different message until it gets reset by the PLC.