LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running multiple instances of an app with a "toggle key" - but can only one use the key?

Solved!
Go to solution

The Subject is probably not very explanatory.  Sorry about that.

 

I've designed an application that can run plug-ins.  The plug-ins can be instantiated multiple times.  One of the plug-ins has a button that uses the "return" as a toggle.  Is LabVIEW not capable of recognizing which instance you're operating in and essentially accepting any return key presses for that specific instance?  Does it only accept it for one instance?

 

I'm seeing that it works and it doesn't work.  For an instance it works, for all others it does not.  But I am not able to determine if when I press enter for another instance if it's trying to send the command for the 'one that works.'  (I think what I am going to do is have the button populate a string letting me know which instance accepted the Return Keystroke)

 

I am using tabs to divvy up the plug-ins.  Assuming it doesn't work as I'd like (the of course easy way) - is there something I need to do programmatically?  I guess I could use the tabs to determine which one is "active."  But the plug-ins are technically independent of the tabs and I'm not loving the idea of adding that dependence.

0 Kudos
Message 1 of 8
(1,123 Views)

How do your plug-ins being loaded? In the form of a subpanel or pop-up subVI?

What do you mean by a toggle key? A Boolean button on the plugin? Or the Enter key from the keyboard?

Can you upload your code and share what your have done so far?

-------------------------------------------------------
Control Lead | Intelline Inc
0 Kudos
Message 2 of 8
(1,108 Views)

Plug-ins 


@ZYOng wrote:

How do your plug-ins being loaded? In the form of a subpanel or pop-up subVI?

What do you mean by a toggle key? A Boolean button on the plugin? Or the Enter key from the keyboard?

Can you upload your code and share what your have done so far?


Plug-ins on a subpanel.

Press Enter on the keyboard triggers/toggles/presses the button in the plug-in.

And I cannot unfortunately.  However, the plug-in is a single VI (that runs without issue - including the button and pressing the return key feature) that is called into a subpanel.  There are multiple tabs all with subpanels.  And that VI is being called multiple times into those subpanels.  The VI is re-entrant.  The entire code works just fine.  Pressing the button works the way intended.  Pressing "Enter" does not.  But it works as intended when I run the VI by itself outside of the Plug-in system, but that is a single instance.

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

@DailyDose wrote:

Plug-ins 


@ZYOng wrote:

How do your plug-ins being loaded? In the form of a subpanel or pop-up subVI?

What do you mean by a toggle key? A Boolean button on the plugin? Or the Enter key from the keyboard?

Can you upload your code and share what your have done so far?


Plug-ins on a subpanel.

Press Enter on the keyboard triggers/toggles/presses the button in the plug-in.

And I cannot unfortunately.  However, the plug-in is a single VI (that runs without issue - including the button and pressing the return key feature) that is called into a subpanel.  There are multiple tabs all with subpanels.  And that VI is being called multiple times into those subpanels.  The VI is re-entrant.  The entire code works just fine.  Pressing the button works the way intended.  Pressing "Enter" does not.  But it works as intended when I run the VI by itself outside of the Plug-in system, but that is a single instance.


You say it works sometimes and sometimes not. I'll assume you are catching the Enter Press as an Event. I believe that Event is only caught when that subPanel is active. There are things that may make that subPanel not active even though it is in the forefront; for example dismissing a right click menu knocks you out of the current pane, if if the mouse is still in it.

Message 4 of 8
(1,075 Views)
Solution
Accepted by topic author DailyDose

The Key Down event is only captured when the subpanel is active (for e.g your cursor is in the control of the subpanel). If your cursor is outside, the event is captured by the main VI. You need to pass the event to the subpanel VI via user event.

I am not sure why asynchronous call and forget does not work but I managed to pass the user event refnum using Set Control Values by Index

-------------------------------------------------------
Control Lead | Intelline Inc
Message 5 of 8
(1,040 Views)

As long as there is only one panel using a specific shortcut loaded into the current top level VI, it should work. But if you have more than one loaded and inserted it it random which one receives the shortcut. Once one of them accepted it it is consumed and gone and will not be passed along to anything else even if you have 100 more panels loaded that would want to react on that key.

 

And yes your subpanel needs of course to have the key focus. That is you need to click once inside the sub panel for shortcut keys to work. The subpanel may look like it is part of the main panel but in reality it is its own window as far as Windows event handling works.

Rolf Kalbermatter
My Blog
Message 6 of 8
(1,009 Views)

@rolfk wrote:

As long as there is only one panel using a specific shortcut loaded into the current top level VI, it should work. But if you have more than one loaded and inserted it it random which one receives the shortcut. Once one of them accepted it it is consumed and gone and will not be passed along to anything else even if you have 100 more panels loaded that would want to react on that key.

 

And yes your subpanel needs of course to have the key focus. That is you need to click once inside the sub panel for shortcut keys to work. The subpanel may look like it is part of the main panel but in reality it is its own window as far as Windows event handling works.


I've attached a very rough sketch of what I'm doing and it looks like, yes... It does not matter which Subpanel you might have "activated", the shortcut is in fact only consumed by one instance of the VI.  Is there a way to resolve this?

0 Kudos
Message 7 of 8
(988 Views)

@ZYOng wrote:

The Key Down event is only captured when the subpanel is active (for e.g your cursor is in the control of the subpanel). If your cursor is outside, the event is captured by the main VI. You need to pass the event to the subpanel VI via user event.

I am not sure why asynchronous call and forget does not work but I managed to pass the user event refnum using Set Control Values by Index


Oops, didn't see this.  This looks like a solid resolution.  Thank you.

0 Kudos
Message 8 of 8
(986 Views)