01-07-2019 11:01 AM
Hello!
I cannot figure out how to make the following function work:
I want an "Are You Sure?" prompt to pop up when a user wants to stop the program.
The attached vi works if you select yes to the prompt and then click anywhere on the screen (besides the buttons). But one shouldn't need to click on the screen again after answering the prompt. And there's many ways to break the program.
Any help is appreciated.
Thank you!
Solved! Go to Solution.
01-07-2019 11:50 AM - edited 01-07-2019 11:54 AM
This is happening becuase you are actioning it on a mouse down event and then opening a modal dialogue which takes focus away from the main window. The value changed event doesn't get fired until the main window receives focus again (would almost say that's a bit of a bug in LabVIEW, but yeah....).
To overcome this I would place generate the dialogue on the value changed event and remove the mouse down event handler completely. This has the added benefit of allowing the keyboard to activate the button as well when activated by the keyboard after being selected with the tab key.
01-07-2019 12:02 PM - edited 01-07-2019 01:00 PM
Windows already has an "exit program" button in the form of an [X] in the upper right corner. That's what users expect to use, so don't define your own non-standard way.
Simply use a "panel close?" Filtering event and "discard" depending on the outcome of the dialog.
01-07-2019 12:09 PM
The above is for the specific question of conditionally exiting the program.
In the more general case, place the dialog followed by a case structure inside the event case and leave the false case empty/wired across.
01-07-2019 12:16 PM
Now I understand why I was getting that odd behavior. Matt's solution worked for me for the general case. Altenbach's solution worked for me for specifically exiting the program.
Thank you both for your responses! I appreciate it! @matt.baker @altenbach
01-07-2019 05:02 PM
@altenbach wrote:
Simply use a "panel close?" Filtering event and "discard" depending on the outcome of the dialog.