LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Default Settings in labwindows CVI 2017

Solved!
Go to solution

By default, the last button that was pressed can be toggled by either the enter key or spacebar as explained in this link.

Operating Command Button Controls - NI

I need to disable all enter and space bar controls for all buttons and switches and only allow use of the mouse. How would I do this? I can't seem to find a guide on this.

0 Kudos
Message 1 of 5
(221 Views)

You can install a callback on the controls, trap EVENT_KEYPRESS events, filter eventData2 field with GetKeyPressEventVirtualKey () function and swallow all but VAL_TAB_VKEY keys. To swallow the event return 1 from the callback function.

Leaving tab key active will permit the user to tab between controls.



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 5
(196 Views)

Hello, thanks for the reply. I'm sort of new to CVI, do you know where I can find more information about trapping events? I can't seem to find it from a google search. is there an example in the NI example finder that has some similar themes? Thank you.

0 Kudos
Message 3 of 5
(128 Views)
Solution
Accepted by CanYouHelp?

If you are new to CVI you should consider spending a bit of time to read some basic text like the Getting Started that you can find in the CVI IDE Welcome page.

 

Basically, you can install a callback on each control you place on CVI panels: the callback is called automatically when the OS intercepts some events or user actions like clicking on the control and so on.

If you open one of the examples that ship with CVI you'll see how the callback functions are defined and handled: trapping the events simply means to add a case to the switch (event) instruction (in your case it could be EVENT_KEYPRESS) and write the appropriate code to be executed to handle the event.

 

I finally suggest you to look at the help for GetKeyPressEventVirtualKey () function and run the example that is mentioned in the help page to understand how to get the key pressed. Swallowing the event simply means to return 1 from control callback function: this will tell the OS not to handle the event like it normally would do and do nothing instead.



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 5
(119 Views)
Solution
Accepted by CanYouHelp?

When I put 

if (event == EVENT_KEYPRESS){
return 1;
}

Inside the call back for the item I don't want to me activated that works for my purposes. Thanks for the help!

0 Kudos
Message 5 of 5
(106 Views)