03-01-2016 12:23 PM
I have a sub-VI that has a bunch of Controls I'd like to map to key presses, so "a", "b", "c" or "d" will toggle one of four Boolean Controls. I've written the code to handle this Event, and it works just fine when I run the sub-VI by itself.
However, I'd like to run this VI in a sub-Panel, and have the key presses passed to the sub-VI's Event Loop. Before posting this Question, I found two similar queries from a decade ago, saying this was a "known behavior for the new sub-Panel feature of LabVIEW 7.0, and is under consideration for a later version". There was also a mention that suggested some clever use of Event Registrations might prove useful.
I'm going to try to puzzle this out, myself, but would appreciate any hints (or outright "solutions") if others have managed to figure this out.
Bob Schor
Solved! Go to Solution.
03-01-2016 01:33 PM
Did you configure the same Event in the top level vi? That is usually the souce of confusion.
03-01-2016 01:55 PM
No, I did not. However, I did some research, and found (not entirely unexpected) this note from NI Help:
So I "inverted" my logic. I had the Key Down? Event in the subpanel VI, with a reference to the Controls (in the subpanel VI) I wanted to affect. I simply moved this Event to the Event loop in the Top-Level VI, passed the reference to the Top-Level before starting the Event Loop, then used exactly the same Event Loop Key Down? code in the Top-Level VI. It's a little "twisted" -- a Key-Down Event (say, "a") in the Top Level VI is trapped by the Key Down? Event code, the "a" is processed and associated with a Control-to-be-changed in the sub-VI running in the sub-Panel, I use the Reference to the sub-VI's Controls to change the appropriate Front Panel Control on the sub-VI, using a Value (signalling) property to make sure the sub-VI knows the Value has been changed.
It worked the first time I tested it! Didn't realize it would be so easy.
Bob Schor
03-01-2016 01:59 PM
Yeah, its a little counter intuative and the Help needs a bit more. But that is exactly the way I've always worked aroud the same issue. Glad you got'r going!
03-01-2016 02:15 PM
I would instead use a User Event to send the key down information to the subVI in the subpanel. Then would have a lot less coupling and reuse would be a lot easier.
03-03-2016 06:55 PM
Crossrulz,
As usual, you were right. I changed my implementation to have the Top Level send the Key as a User Event to the sub-Panel, definitely more straight-forward (and, needless to say, it worked, though not the first time, as I forgot to update a shift-register value in the sub-Panel ...)
Bob Schor