ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Keydown filter event not working.

Solved!
Go to solution

The attached file includes a sub-vi (Dropdown Menu) with its wrapper code isolated from the rest of the program and used as the main vi (Dropdown Ring).

 

I currently have three ways of 'exiting' the dropdown menu; two that work and one that doesn't. The one that doesn't is the keydown event. This is currently defaulted as the Escape key, but I haven't had any joy with other keys either.

 

Could someone possibly check my code to see what I might be doing wrong? At the moment, the keydown event never seems to occur which has me rather confused as to why.

 

There are a few 'extra' controls on the main vi's front panel, but these are mainly for debugging purposes.

 

 

Attachment: (LabVIEW 8.5)

  • Dropdown Ring - Main VI
  • Dropdown Menu - Sub VI


Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 1 of 5
(4,232 Views)

Hi James,

 

two points:

- the ESCAPE key isn't working because your subVI doesn't get focus. You first have to click into the selection area before key down events are recognized in the subVI...

- I would include the setting of the origin back to (0,0) into the subVI. While playing around a moved the FP of the VI, which leads to an "empty" window shown later on. (just for safety...)

Best regards,
GerdW


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

That's a good point about setting the origin to (0,0) - I find it's best to try to account for every eventuality when dealing with user inputs!

 

And thanks for pointing out why the Keydown event wasn't working. Is there a way to programatically give focus to a VI, or will that interfere with something else? (I'm not at the office again until Monday)

 

- James

 

 

P.S. As a personal opinion, do you think I even need the Keydown exit strategy as well as the two timed exits?



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 3 of 5
(4,207 Views)
Solution
Accepted by J.Mamakos

Try setting the menu subVI to "modal" in the customized window appearance properties. Now <escape> seems to work just fine.

0 Kudos
Message 4 of 5
(4,196 Views)

@altenbach wrote:

Try setting the menu subVI to "modal" in the customized window appearance properties. Now <escape> seems to work just fine.


That worked.  I had to tweak the boundary calculations to account for the compulsory modal border, but it does what I need.  🙂

 

Including the new VI, for if anyone stumbles across this thread later.



Never say "Oops." Always say "Ah, interesting!"

0 Kudos
Message 5 of 5
(4,178 Views)