From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handling Cut/Copy/Paste menu items

LV2013, Win7

 

Relatively new to menus.

 

I have an app that uses menus, there are 8-10 windows, each has more or less the same menus.

For that reason, I build the menus in code (not using .RTM) and every window calls  one VI to set up the window, one VI to validate it, and one to handle selections and generate events for those selections.

 

When each window initializes, I set up the menus.

 

In the MENU ACTIVATION? event (when the user has clicked on the menu bar), I have a VALIDATE MENU function, which alters the menus by enabling this, or disabling that, or creating the list of open windows, based on current conditions.

 

One of the menus is EDIT, where I have CUT, COPY, and PASTE items, with the standard APP_CUT, APP_COPY, APP_PASTE tags.

 

I do not validate that menu at MENU ACTIVATION? time, yet the items are enabled / disabled properly (if you have a text selection, you can CUT or COPY it, if the clipboard contains text, you can PASTE it).  The shortcut keys are there, it's just automagically set up and it works.

 

But I have one window where I want to apply the CCP logic to a TREE control.  You can CUT, COPY and PASTE things from this tree (using other commands) now, but I'd like to keep the standard behavior of the EDIT menu (if you're focused on a text/numerical field, enable them the way they  are now), but if you're focused on the tree, then apply my own logic (I have a clipboard of my own for these tree items).

 

What's the best way to share the menu?

 

I suppose I could, in the VALIDATE function, see if my TREE has focus, and then substitute my own tags for the standard (APP_CUT) ones.

Does the standard validation procedure interfere with that?  I don't want the system to disable the thing just because it's not a text field.

I don't know where the enable/disable code occurs.

 

Any better ideas?

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 1 of 3
(3,028 Views)

Hmmm.  Looks like, when using the INSERT MENU ITEMS function, if the TAG you provide is APP_CUT (APP_COPY, APP_PASTE), then it doesn't matter what you provide for the item NAME (if anything), the name it uses is CUT (Copy, Paste), and the enable disable behavior is there.if you provide some other tag, then the name is yours, and no behavior is provided for you.

 

But, if I switch tags at MENU ACTIVATION? time, has it already decided on CCP behavior based on the existing tags, or will it adapt to the new tags I provide?

 

I guess we'll find out...

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 3
(3,007 Views)

OK, that works, although I'm not happy with the results.

 

Here's what I'm doing:

 

1.. At INIT time, create the EDIT menu, but leave it empty.

2... At VALIDATE time (Menu Activation? event), check if the tree is focused.  Most windows doen't have a tree, so the option is OFF.

3... At VALIDATE time, if the TREE is FOCUSED:

3a...     Delete the standard APP_CUT, APP_COPY, APP_PASTE tags from the EDIT menu. (ignore error if not there).

3b...     Insert my own CUT, COPY , PASTE items, with custom tags.

3c...     Add the shortcuts to those items.

4...  ELSE

4a...    Delete the custom CUT, COPY, PASTE items. (ignore error if not there).

4b...    Insert the standard APP_CUT, APP_COPY, APP_PASTE tags  (the shortcuts follow automagically).

 

It does what I asked for.  Trouble is, the TREE control doesn't have a visible indication of its KEYFOCUS status.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 3
(2,960 Views)