LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

keydown events in subpanel

I have read some other posts about this sort of problem, but the solutions offered there have not worked for me.  What I want to happen is the VI in the subpanel should respond to keydown events.  Everything I have tried to get this to happen has been intermittent at best.  What usually happens is that a mouse click on any control or indicator in the subpaneled VI will then cause all keydown events to work on the VI as I wish, but you have to do that initial mouse click first.  Does anyone know how to get a VI in a subpanel to respond to keydown events as soon as the VI starts running in the subpanel without any other interaction in the subpanel first?  Assigning keyfocus and registering for events are the general suggestions in other threads about this sort of situation, but none of that has worked for me in the desired fashion.  I am using LV 8.0.1 on WinXP if any of that matters.
0 Kudos
Message 1 of 7
(4,215 Views)
Hello,
It is very curious that you must have an "initialization" click of the mouse to trigger the keydown events. Perhaps you might post a skeletal version of your code that exhibits this behavior.
In addition, have you already reviewed the example library provided on the NI website that will programmatically fire an event in a subpanel? It might be useful since it has extensive comments within the code that details the functionality.
Cheers
 
0 Kudos
Message 2 of 7
(4,199 Views)
Hi eek:
I have a deadline looming on another project until Friday, so I will be a little slow on following your suggestions.  I can have a simple demo version Friday or Monday if not sooner, and I will look at the example you referred to in the meantime.
Bart

0 Kudos
Message 3 of 7
(4,186 Views)
I think the initialization click is needed because the subpanel is not the active vi until it has been clicked. If you had two VI's running in separate windows only the currently selected vi receives key events. The difference with a sub panel is that the containing vi also receives any keydown (and mouse, and maybe other) events that the subpanel vi receives. Hopefully that makes sense and is correct.

The solution is very similar to the link eek provided. Get a reference of the containing vi into the sub panel vi, and hook that reference up to registry for events, and select keydown. Then hook the event registration refnum to the event structure. And set it up the event structure to handle the dynamic event.
0 Kudos
Message 4 of 7
(4,185 Views)
OK, the basement flood is fixed for now, and the deadline was met on Friday.  Here is a little demo of the problem.  The basic idea is that the subpanel will be used for several different little recipe guides like the one included.  Other things in the code could require bailing out of the recipe, so there is a global to force an early exit, but normally you would exit when the last step in the recipe finished.  The code does things based on where the user is in the recipe, so waiting for the user to press any key is the way the code knows when to do the next step.  I want the user to have to do nothing extra to get the keydown to work right from the beginning.
0 Kudos
Message 5 of 7
(4,155 Views)
You have three problems.

1. Your not getting the right VI reference in the subpanel vi. Call chain only works if the VI was called as a subvi, not by reference. The quickest fix is to use a static vi reference and drag the main vi's icon onto it (I could list others if you need something more adaptable).

2. You need to wire the vi reference into the the regevents not it's controls. That way you catch keys while the vi window is active, currently it'll only catch keys while a control on that vi is active (like typing in a string control).

3. Your event loop is set to the wrong event. You need to use the dynamic, key down event not the <this vi> key down event.




Message Edited by Matt W on 02-27-2007 01:37 AM

Message 6 of 7
(4,150 Views)
Hi Matt:
It works now.  I knew some of those things, but didn't see them when the simple first try at this didn't work.  And 2:36AM?  I hope that means you are not on the US East Coast.
Bart
0 Kudos
Message 7 of 7
(4,135 Views)