LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I map keys (of a keyboard) to CVI controls

Instead of the mouse I would like to use keyboard keys to control buttons in CVI. Is there a sample code example ?

Thanks
0 Kudos
Message 1 of 4
(4,560 Views)
You have several ways to operate via the keyboard instead of mouse:

1. Create a shortcat letter in the controls' labeles by addint a double underscore to the desired letter. For example: __Ok will show the "O" underlined and the control will be operated by pressing Alt+O
2. You can associate a shortcat key to the control in the UIR editor, so that a button is operated by a key in the keyboard or by a combination of keys such as Ctrl+Home and so on
3. Menu items too can be operated via a shortcut key defined in the Menu editor of the UIR editor

All of these methods need no lines of code to add to your application.

Be careful: all these methods do not operate if the panel the controls are on is not the active panel.

If you need to respond to
keyboard events not related to some control on a panel or valid for all panels in the application, you can define a main callback (InstallMainCallback) and trap the proper event in it.

Hope this helps
Roberto


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 2 of 4
(4,561 Views)
Hello Roberto, others

Your last comment about "keyboard events valid for all panels in the application" is probably what I need.
I currently have a menu in the main panel. In this menu, I assigned shortcut keys to some of menu entries. I would like to have those shortcut keys working on all panels I have. One option is to use the same menu in all panels, but I did not find a way to hide the menu (because I don't want it visible/using space in my other panels). The other seems your
InstallMainCallback() proposal. To avoid redundancy, I'd need to grab all shortcut definitions from the main menu and use them in myMainCallback. I'd like to keep the master shortcut definitions in the main menu, because the shortcut key shows up in the menu.
Am I on the right track, or are there other suggestions?

Matthias

0 Kudos
Message 3 of 4
(4,344 Views)
Hi Matthias,

What you are saying sounds reasonable. Just call InstallMainCallback and in the actual callback method, compare the event with all the shortcut keys obtained from GetMenuBarAttribute(ATTR_SHORTCUT_KEY).

Regards,
0 Kudos
Message 4 of 4
(4,319 Views)