LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure

Solved!
Go to solution

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

Thanking you,
Sushmith
0 Kudos
Message 1 of 9
(3,144 Views)

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...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,135 Views)

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

Thanking you,
Sushmith
0 Kudos
Message 3 of 9
(3,126 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 9
(3,119 Views)

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.

0 Kudos
Message 5 of 9
(3,104 Views)

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

Thanking you,
Sushmith
0 Kudos
Message 6 of 9
(3,086 Views)
Solution
Accepted by topic author sushmith_ks

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 9
(3,058 Views)

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 

Thanking you,
Sushmith
0 Kudos
Message 8 of 9
(3,003 Views)

Hi sushmith,

 

attach your VI to allow us to search the problem...

Best regards,
GerdW


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