LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Return from dynamic loading vi loses focus

Solved!
Go to solution

Followng the Dynamic Loader.vi NI Example, my vi loads, runs and returns properly.  Howerver, when using the same calling code from my main program, the same vi loads and runs, but on return the focus is not on the original vi.  A mouse click on the screen is required to restore the focus.  Since my program is heavilly keyboard based, this is a nuisance, and users may think that the program has frozen.

0 Kudos
Message 1 of 8
(2,894 Views)

 

  1. How is the "Window Appearance" section configured on both your Top Level and the dynamically launched VI?
  2. Are you calling any methods on the dynamically launched reference that would change it's appearance or appearance functionality?
  3. How are you shutting down the window of the dynamically launched VI?
  4. Is it possible to upload a stripped down version of your code that exhibits the same behavior?

 

Message 2 of 8
(2,887 Views)
Solution
Accepted by topic author rmtripp

Examining the Window Appearance showed that in the Dynamic Load Example.vi the Show Front Panel and Close Panel were checked.  These were not checked in my program.  When checked, this seemed to solve the problem. 

 

It seems that the first vi needs these two items in order to take focus back on return from a dynamically loaded vi.

 

Thanks for the advice.

0 Kudos
Message 3 of 8
(2,874 Views)

That sounds an awful lot like Jack's point #1.

 

Spoiler

If that is indeed what pointed you in the right direction a cool move would be to mark his post as the solution.

Message 4 of 8
(2,867 Views)

Exactly.  Following Jack's #1 point was the basic solution.

 

However, there is a second part to the problem.  If this is run during LabVIEW debugging and other windows are open, such as the Project Manager or other vi panels, then on return from a called vi, the focus may go to any one of the windows and not necessarily to the calling window. 

 

This is probably not a problem when the program is compiled and run normally, but I have not tried that yet.  Making sure that all other LabVIEW windows are closed during testing seems to do the trick.

0 Kudos
Message 5 of 8
(2,844 Views)

rmtripp wrote:

 

However, there is a second part to the problem.  If this is run during LabVIEW debugging and other windows are open, such as the Project Manager or other vi panels, then on return from a called vi, the focus may go to any one of the windows and not necessarily to the calling window.


You just described expected behavior... when the interrupting Modal or Floating window pops up and then you dismiss the window, expected behavior is return to whatever window last had focus. If you wanted the UNEXPECTED behavior of always returning focus to the caller diagram, you would require the child window somehow know it's caller (Call Chain if statically called, some reference and VI server acrobatics if dynamically called) and have the child window explicitly reset focus to the caller window.

0 Kudos
Message 6 of 8
(2,830 Views)

@rmtripp wrote:

Exactly.  Following Jack's #1 point was the basic solution.


Then read Solution Etiquette

0 Kudos
Message 7 of 8
(2,821 Views)

As rmtripp points out, my post was not exactly the Accepted Solution, so perhaps it's not a good candidate for imposing the 'Solution Etiquette' thread (which is still in the 'rough draft' stages).

 

Just a little bit of background, if you're not aware, rmtripp: nobody knows exactly how to use the "Accept as Solution" button on these forums.... even people who have been on the forums for years don't have a "definitive" answer yet on what constitutes an accepted solution. The thread Ravens linked to is an attempt to get a 'group consensus' on how the Solutions metric should be handled, and how regular board members (those with dark orange rank bars, and especially the Knight of NI status) should enforce the use of the Solution. Feel free to read through the thread and add your opinion, but bear in mind it's not complete.

0 Kudos
Message 8 of 8
(2,814 Views)