07-22-2010 05:37 PM
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.
Solved! Go to Solution.
07-22-2010 09:33 PM
07-23-2010 09:22 AM
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.
07-23-2010 09:29 AM
That sounds an awful lot like Jack's point #1.
If that is indeed what pointed you in the right direction a cool move would be to mark his post as the solution.
07-23-2010 11:41 AM
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.
07-23-2010 12:18 PM
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.
07-23-2010 12:58 PM
@rmtripp wrote:
Exactly. Following Jack's #1 point was the basic solution.
Then read Solution Etiquette
07-23-2010 01:11 PM
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.