LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Hot Keys toggle state of toggle switch

Solved!
Go to solution

How can I prevent a toggle switch from updating it's GUI state when it is accessed via Hot Key (Alt + letter)?

 

I want to be able to do this without Disabling the control,  and without setting the control to Indicator mode.  I created a callback to swallow the event_commit.  The control still toggles state when using hot keys but not when clicking the control. 

0 Kudos
Message 1 of 4
(3,020 Views)

Apart deleting the hotkey from the control (stripping away the double underscore in the label name) you should be able to avoid user interaction via the keyboard by swallowing EVENT_KEYPRESS.

 

But if control does not toggle neither via the mouse nor via the keyboard, how do you intend to operate on it? Isn't this state similar to putting it in indicator mode? Unless you want to filter out only some keys but not all: in this case this help page can guide in discriminating keyboard presses.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 4
(3,016 Views)

Swallowing EVENT_KEYPRESS does not prevent the Hot Key from toggling the state of the switch.

 

We have 5 separate applications that can operate in two modes: Manual and Automatic.  In manual mode, the operator has full control over the GUI widgets.  In the new automatic mode that we are adding, the operator cannot control the GUI widgets; only the external server can send commands to the application and control the GUI widgets.

 

We would prefer not to modify the original applications. We want to add the "Automatic" mode on top of the existing applications.  Therefore, we would rather not remove the Hot Keys. We want to see if there is a better way to do this besides setting the controls to Indicator mode, because we want the state of the GUI controls to represent the state of the application after exiting Automatic mode and entering Manual mode.  We could remember the caption of the control and strip the Hot Key while in Automatic mode, and restore it in Manual mode. But if the caption of the control changes when in Automatic mode, the caption will not be in sync when it is restored in Manual mode.

 

We currently chain an "inhibit" callback to the callback event chain that swallows all events. For some reason everything but Hot Keys are inhibited.  You would think swallowing the "EVENT_KEYPRESS" would restrict Hot Keys.  I guess this is a Windows feature rather than a LabWindows feature.

0 Kudos
Message 3 of 4
(3,011 Views)
Solution
Accepted by topic author softengr

While thinking about your problem it has occurred to me to experiment with some SDK function to check whether the accelerator key function could be diabled. While I haven't succeeded in it, I have noted that if you install a system hot key via RegisterHotKey SDK function it has precedence over the accelerator CVI installs while adding a double underscore somewhere in the control label. That is, even if the accelerator sign is present, a system hot key comes before and prevents the button callback to be fired. That could be a feasible solution for your actual problem.

 

I made up a fast example that shows all this matter: you can test all combinations of hotkeys installed on the control and see what happens.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 4
(2,992 Views)