04-26-2013 12:58 AM
Hello,
I have used event structure in my VI with key press event. But the problem is the event gets activated if I press any key from keyboard. My requirement is event structure should be activated only if I press some specific key from keyboard. Is it possible? If so, how?
Thanking you,
sushmith
Solved! Go to Solution.
04-26-2013 01:24 AM - edited 04-26-2013 01:30 AM
Hi sushmith,
the event structure provides you also with information on which key was pressed at their event property data node. You have to use some comparison functions and a case structure when you want to limit actions on specific keys...
04-26-2013 01:51 AM
Hello,
I have an event structure where comparision is done for left and right button. That is working fine, but whatever the key is pressed from keyboard control will be passed to event case, but I want to pass control to the evnt case only if I press left or right button.
thanking you,
sushmith
04-26-2013 02:10 AM
Hi sushmith,
as said before: you have to use some comparison function (and/or case structure) to know which key has been pressed. See the help for that event!
04-26-2013 02:58 AM
Hi Sushmith,
Gerd is right about the comparison, you just have to filter the keys.
In addition, you can also filter the event itself and discard the fact that you pressed a key if you don't want it to be pressed (for example Return, Enter, or Escape). You just have to select a Filter Event "Key Pressed ?" and discard it in certain circumstances. The attached example will only aknowledge the user to press the Space bar key. All the other keys will be ignored.
Eric M. - Senior Software Engineer
Certified LabVIEW Architect - Certified LabVIEW Embedded Systems Developer - Certified LabWindows™/CVI Developer
Neosoft Technologies inc.
04-26-2013 05:25 AM
Hello,
I'm using Labview Full Developement system 2011, I'm not able to run the vi you have attached ( It is giving me error saying version is different) . So please convert the vi to lower version which is compatible with my software or kindly attch the snapshot of the block diagram.
Thanking you,
sushmith
04-26-2013 08:48 AM - edited 04-26-2013 08:49 AM
It is probably not a good idea to use the Key Down? filter event. You can block typing into controls if you do that. The event structure is going to see any key press. There is no way around that. But you can check to see which key was pressed (use a case structure) and react only to the keys you care about. In this example, I am exiting when you press the ESC key.
05-02-2013 06:15 AM
Hello,
This is working fine. Thank you. I still have one problem. I have a tab control of 4 pages. The above mentioned switch arrangement is placed in page 3 and 4. these arrangements are interconnected. I meant to say if button 1 in page 3 switched on, button 1 of page 4 also should be switched on. Even that is working fine.
Unfortunately, till I press short cut keys everything will be fine, but once i press shortcut key then switching between pages (mainly 3 and 4)will be problem. i.e when I press page 4, tab control will go to page 3 first and then come to page 4. same case for page 3 as well. what may be the reason?
Note: page1 to 4 are controlled by shortcut keys F1,F2,F3,F4 without event structure. its done by direct shortcut key to different buttons.
Thank you,
sushmith
05-02-2013 06:40 AM