I am having an issue with this in vision. I have a script on the actionPerformed, and it fired no matter what the user picks for the confirm message "Are you sure".
I might be missing something but I could not find out how to run a script only if user selected yes for a vision one stop button's confirm property being turn to True, and wait for a use choice.
That said I am trying this workaround it but can not figure out how to access the users choice for that confirm question:
My thought process is something like this but this only grabs if the confirm property is selected right now. Is there a way to grab the users answer via script?
if event.source.confirm == True:
do the thing
The user's choice is the return value from that function. Please show your code so we can be more specific with our advice.
My code is on the actionPerformed. It runs once the button is clicked and does not wait for the confirm choice.
Task_ID = event.source.parent.getComponent('Power Table').Task_ID
if event.source.confirm == True: # but look for the user choice
system.db.runNamedQuery('myQuery', {'prams':Task_ID })
Where is your call to system.gui.confirm()
? That isn't optional.
1 Like
Ah so I need to make my own gui...I can do that
.From the one shot button doc I was under the impression nothing will work until the confirm choice that is built in pops up. Then if the user choices "Yes" then it does the thing, and "No" nothing happens.
If this is the case ill just make a regular button to do all this, and delete the on shot button.
Edit.
I kept the one shot button, turned off the confirm property or it'll pop up twice if you do not, and this is my final code:
Task_ID = event.source.parent.getComponent('Power Table').Task_ID
useChoice = system.gui.confirm("Are You Sure")
if useChoice:
system.db.runNamedQuery('QueryPath', {'pram':Task_ID })
Ah, it turns out I've never used the one-shot button or it's built-in confirm function. I would expect that the actionPerformed
script would simply not be run at all if that built-in confirmation was rejected.
I strongly recommend not using system.gui.confirm()
, nor its popup peers. They block the entire GUI while open. Instead, use a two-stage confirmation with ordinary buttons, and possibly timers. Where a 1st button enables a 2nd button, possibly for a limited time, or until the 2nd button is clicked. No further confirmation needed.
2 Likes