LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Send focus back to main VI window

Solved!
Go to solution

Actually, the scenario is a bit more complicated than the subject describes.

 

There is a main VI which has a user interface and uses an Event Structure to capture / process operator events.  This same main VI also calls Dynamic VIs.  One of which has its own Event Structure.  The code for both VIs was developped using LVOOP.

 

There are hotkeys associated with the main vi.  However, because the main VI spaws the Dynamic VI, the Dynamic VI has the active window.  As a result, all keyboard events are being processed by the Event Structure of the Dynamic VI (of course).

 

However, when a keydown event is triggered, it should be captured by the main VI.  The code architecture cannot be changed.  What would be an appropriate method to either make the main VI the active window (thus able to process keyboard events) or to be able to pass keydown events along with the captured event to the main VI without making an overhaul of the architecture?

 

Some ideas would be to register external events (which are sent to the main) and create a keydown event in the Dynamic VI.  This may require implementing a queue.  Or since the code uses LVOOP, then creating a lvclass to handle keydown events might be the way to go.

 

I simply want to get some feedback on potential "gatchas" that may be lurking when trying to implement a solution.

 

Or maybe there is a simple trick that I have not considered.

 

Thanks,

 

RayR

0 Kudos
Message 1 of 8
(3,435 Views)

When you launch/spawn the 'dynamic vi's, you have a reference. Obtain the events from that ref, dynamically register them and unregister them when this vi is done (panel close event).Smiley Very Happy

 

Felix

0 Kudos
Message 2 of 8
(3,416 Views)
Solution
Accepted by topic author Ray.R

Don't know much about your LVOOP but I assume you know of the VI property, FP.Run-Time.Minimized, to minimize the dynamic VI from the Main VI or in the dynamic VI itself.

 

Or you can use the Application method "Bring To Front" after spawning the dynamic VI. This will give keyboard focus back to the Main VI. I believe in KISS.

Message 3 of 8
(3,414 Views)

Here a snippet of my idea, didn't check if it would work, the default register events (init part) didn't accept Not-A-Refnum.

 

RegisterVIEvents.png

 

Felix

0 Kudos
Message 4 of 8
(3,403 Views)

I believe in KISSes, too.  Only with women, though..  😄

 

Wow..  we tend to overcomplicate things sometimes..

 

All that was needed was this VI property node with a TRUE boolean wired to FP.IsFrontmost.

 

Thanks richjoh!

0 Kudos
Message 5 of 8
(3,385 Views)

Felix,

 

The example you suggested was exactly what I had in mind.

 

Strangely... I'm sure I tried the FP.ISFrontmost property before..  But I can't remember... But if I did, I suspect I put it too close to where the Dynamic VI was being called, thus causing the main VI to be frontmost to then be superseded by the Dynamic VI which takes a while to fully load and execute (lots going on).

 

I placed the FP.IsFrontmost in the default "idle" state and it solved it.  I will try to find a better place so that it does not get called all the time.. Although it might not hurt anythong other than performance.  At least I have a solution.

 

Thanks guys!

 

🙂

0 Kudos
Message 6 of 8
(3,381 Views)

Felix,

 

I have to ask...  Was the snippet done using LV7.1?  (I know that feature didn't exist so the code capture tool, but LV7.1?)

 

0 Kudos
Message 7 of 8
(3,369 Views)

CCT is allowing to create snippets even down to 7.1

Basically it just needs to get the selected code via scripting, save it to a temporary file and attach it to the png.

But of course the older LV versions don't have the ability to drop a snippet on the BD. I'm unsure if there is already a solution around.

CCT is really a great tool with a lot of big contrubution by some of the best members of the community.

 

Felix

 

Message 8 of 8
(3,343 Views)