LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Don't undo the boolean operations

Hi
I have a boolean control (Switch when pressed) in the FP and handled the value change event for the same.
While the VI is running, If I click the boolean and then press Ctrl+Z then it triggers the value change event.

Is there any way to discard this event change?

0 Kudos
Message 1 of 6
(2,729 Views)

Hi Padmanaban,

 

While the VI is running, If I click the boolean and then press Ctrl+Z then it triggers the value change event.

Does it handle that event before or after you press Ctrl-Z?

In case "after": why does your VI don't handle the value change event instantly?

In case "before": how do you want to undo an already handled event?

 

- When you need an Undo feature in your software you need to implement it on your own!

- When there can be problems due to misguided user input you need to prevent the user from such inputs! So yu better create a kind of "Do you really want to handle that event?" dialog before executing that "value change" event…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,723 Views)

There's a couple of ways which work after a quick test. One option is to create a custom run-time menu which doesn't include any Ctrl+Z / Undo shortcut. For example a simple menu with a File -> Exit command will work. If you do this, you need to handle the custom menu option (Exit) with an event structure.

 

Another option is to capture the Key Down? filter event on the VI, and discard the key press when Ctrl+Z is pressed. In this example the code checks if Ctrl is being pressed while the z key (scan code 44) is pressed. If so, the key press is discarded and LabVIEW never processes it.

ctrl-z.PNG

 




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 3 of 6
(2,716 Views)

Hi GerdW,
Thanks a lot for the reply. Actually, the value change event is triggered after the Keydown event. 
Also, I'm using some other controls in the GUI like String etc which requires undo option to undo their typed texts. So, I cannot discard the respective key-down event directly.

0 Kudos
Message 4 of 6
(2,694 Views)

Hi Padmanaban,

 

so there is a problem in your VI - but you don't attach that VI.

I guess you need to solve your problem on your own…

 

Actually, the value change event is triggered after the Keydown event.

Why?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(2,692 Views)

Keeping undo functionality while ignoring only Boolean changes is tricky, but still doable.

 

One workaround is to separate all of your boolean controls into a separate VI, and insert that VI into a sub panel on your main interface. This way when Ctrl+Z is pressed on the main VI, the sub panel VI will not receive the Key Down event. Any value change events for the booleans can then be communicated back to your main VI with a User Event.

 

The more complete solution would be to manage an undo history within your application, separate to that of LabVIEW. Every value change event (and corresponding control ref) could be stored in a queue, and when Ctrl+Z is pressed, you step back through the queue and reverse each value change. There will no doubt be corner cases which need handling and is extra effort, but this way will let you filter any value changes on buttons / booleans.

 

Edit: Very quick and dirty sub panel example attached. Run ignore_ctrlz.vi, then click the boolean in the sub panel and type some text in the string control. When pressing Ctrl+Z, the boolean value change won't be undone, only the changes on the string.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Download All
0 Kudos
Message 6 of 6
(2,654 Views)