In my current project I am using several DQMH modules that can be displayed during a test sequence for the user. Each of these user interface modules are to be loaded into a subpanel with certain ones requiring a particular control to be made focus using the key focus property node.
This is where I’ve come across an issue with my code – the key focus property node doesn’t work when the module is displayed in a sub panel. This is an issue for the project as this is a main feature in the project.
Any suggestions on how to get this feature working would be most appreciated.
Solved! Go to Solution.
There's something else going on in your code, I verified that setting key focus of a control in a subpanel should work fine. See the attached example and run the main VI (saved in LabVIEW 2020). After a second, you'll see the numeric control in the subpanel gets key focus and you can modify its value with the keyboard.
If you can attach a simple project that demonstrates the issue I can help you troubleshoot it.
Thank you for confirming that the key focus routine will work in a sub panel.
As requested, – please see the attached sample project which only contains the main module (server) which has the sub panel and the UI module (Manual Test) in question that should have key focus on the indicated control. Sample saved in LabVIEW 2017.
In the server module press the green play button to display the Manual Test in the sub panel.
I’m not sure if something else is happening to take the key focus away from the indicated control.
The key focus is set in the Set display & the Show in sub panel states of the UI module.
You have a race condition in your code. The VI must be displayed in the subpanel before setting the KeyFocus. More generally, a front panel must be visible before setting KeyFocus has any effect. Here's what I did to fix the issue in your code:
The Merge Errors function enforces data flow such that the VI is inserted into the SubPanel before setting KeyFocus.
I'd like to point out that you aren't actually using LabVIEW Sub Panels. You are using some kind of MDI code that just uses the sub panel as a location definer. You never actually use "Insert VI" into the sub panel, and your MDI window is floating just above the sub panel. Actual use of the sub panel would not give the "window-in-a-window" MDI effect I assume you want, but it would be a lot simpler.
Thank you for your help in resolving this issue.
I will amend my code for this fix to prevent any further race conditions.
That is true – the code is using win32 API calls to mimic a MDI interface. I agree that a sub panel approach would be simpler, but the end user likes MDI style interfaces and likes to be able to have an image that can be displayed in the container window.