LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Copy and paste from sub panel

I have a main VI with a sub-panel.  I have the main VI's menu enabled with copy and paste, but if I select text in the sub-panel, those menu options get disabled in the main VI and I cannot copy or paste to/from controls in the sub-panel.  Copy and paste to/from controls in the main VI work fine.

 

The sub-panel also has its menu enabled, but it doesn't show when called as a sub-panel.

 

How to get this to work then?  All I want to do is have copy and paste for my entire main VI (Including the sub-panel).


Thanks,

 

XL600

0 Kudos
Message 1 of 6
(3,289 Views)

I think I figured out a method, but it's pretty ugly:

 

The problem is that the menu events of the sub-panel do not fire.  There's also no connection between the focus object of the sub-panel and the menu response of the main VI.  What I did then was to use the Key Up event to detect the Ctrl-C and Ctrl-V combinations in the sub-panel.  Retrieving the 'in focus' sub-panel control, detecting its type, and performing a copy or paste (At the selection point) seems to work pretty well.  It's clunky and only works properly if the subpanel is run as a subpanel (Otherwise, the copy and paste menu event also fires and you wind up doubling up your text).

 

Untitled.png

 

This seems overly complicated to me and I would hope there's an easier way.

0 Kudos
Message 2 of 6
(3,254 Views)

@xl600 wrote:

I think I figured out a method, but it's pretty ugly:

 

The problem is that the menu events of the sub-panel do not fire.  There's also no connection between the focus object of the sub-panel and the menu response of the main VI. 


(Not sure if I get the situation right, might be completely wrong, but maybe not.)

 

The main VI doesn't get any events of the VI in the sub panel. The VI in the sub panel get's those events. The main VI's events are not automatically extended with the sub VI's events. It's only the front panel that is shown in the sub panel.

 

If you want the main VI to get sub VI events (in sub panel or not), you need to register for those events. Or handle them in the sub VI.

 

If you use dynamic event registration, be aware that it will give an error if the panel of the sub VI is closed. You need to open it, insert it in a sub panel, or hide it to register for control events. But to put it in a sub panel, the panel needs to be closed. So if it doesn't work, check the error out of the dynamic event registration. This is a likely source of the error.

0 Kudos
Message 3 of 6
(3,236 Views)

And also, are run-time menu's enabled? Right click the sub panel, Advanced>Run Time Menu>Enable.

 

Are run time menu's enabled in the sub VI? Does it work when the VI is not in the sub panel? If not, it won't work in the sub panel.

 

This has never been a problem for me, so something is wrong. Not sure if it's an option, or your approach. We'll get to the bottom of it.

 

0 Kudos
Message 4 of 6
(3,235 Views)

The run time menu is enabled in the sub-vi and copy/paste works fine if the sub panel VI is run by itself.

 

You mentioned dynamic registration so the top VI ets the sub-vi's events?  How would  that be done?  Copy/paste events aren't actually handled by user code in an event structure.

 

Thanks!

 

p.s I guessed it might be straight forward, but the exercise in re-creating copy/paste handling was instructive regardless.

0 Kudos
Message 5 of 6
(3,218 Views)

Well, normally this is no problem. You should be able to copy data from a VI in a sub panel, and paste it in a control in the main VI. You shouldn't have to do anything for that.

 

So I don't know where to go from there. It could be that I didn't understand the problem right. If it doesn't work for you, there must be something tin your code that prevents this. It's hard to say what that is without seeing any code.

 

Dynamic event registration isn't hard, but you shouldn't need to use it for simple copy-paste behaviour. Use "Register For Events", wire control, VI, pane or panel reference to it. Wire the Event Registration wire to the dynamic event terminal (right click "Show Dynamic Event Terminals"). Add the dynamic event, and you'll get dynamic events. Very powerful, but not easy to grasp in it's full extend. For instance, you can change those registrations in the event structure itself, to enable, disable or change what events you get.

 

 

0 Kudos
Message 6 of 6
(3,209 Views)