Jump to content

Control -> User Run-time Menu Checkmark?


orko

Recommended Posts

Hi all,

I've been beating my head against this for hours...so it's time to ask for help. :headbang:

I've created a run-time menu and saved it to disk for a numeric control with one selection item, let's say its named "foo" and is located in "menu1.rtm". I can then attach this menu to my numeric control and create an event structure handling the event: "foo: Shortcut Menu Selection (User)" to trap when someone selects this item from the menu. This works as desired.

My problem is, how can I check/uncheck the selection in the menu as I can do using the "Set Menu Item Info" menu primitives for application menus?? I don't see where I can get the MenuRef of the user rtm from within my event structure... I can only get the control reference, Item tag, Item path, and something called a "SubObj" (not at all sure what this is).

My goal is to perform one thing when the user "checks" the selection, and another when they "uncheck" it.

Thanks for any pointers!

Link to comment

As far as I know, the MenuRef is valid only in the menu activation frame. LabVIEW Help is quite specific about this:

MenuRef: Reference to the control shortcut menu that you can modify during this event. MenuRef is valid only during this event case.

Unfortunately, in my opinion, this is an annoying shortcoming of the shortcut menu implementation in LV 8.x (no pun intended).

Also, NI shipping example "Run-Time Shortcut Menus.vi" is very misleading. For instance the Menu Selection has a MenuRef output (I have no clue how to get this outside of this VI since this is not one of the event data field available [even the help does not mentioned this field]) and if you check the reference validity it is always invalid.

post-121-1171591602.png?width=400

Another error is in the mouse down frame where a comment "Programmatically generate the Menu Activation event when the user right-clicks on the Listbox control" let you believe than you need to fire a value change to programatically generate the menu activation event. This is completly inacurate, and that frame can be deleted all together.

post-121-1171591589.png?width=400

Anyway, sorry I could not help you more.

PJM

Link to comment

Ya, I believe this is an oversight on NI's part, however there is a workaround, albeit cludgy. You need to trap the menu Activation event. From there you can detect the state of the checkmark with the "Get Menu Item Info" menu primitive. Then you need to pass that state boolean via a shift register to the menu Selection event case. You don't even have to worry about initializing the shift register since the menu Activation event always fires before the menu Selection event case

Link to comment

QUOTE(PJM_labview @ Feb 15 2007, 06:19 PM)

Also, NI shipping example "Run-Time Shortcut Menus.vi" is very misleading. For instance the Menu Selection has a MenuRef output (I have no clue how to get this outside of this VI since this is not one of the event data field available [even the help does not mentioned this field]) and if you check the reference validity it is always invalid.

I see that too...that is strange to have a MenuRef in that example, but I believe you are right that you can't actually *use* it for anything, since it's invalid in that event case.

This is really annoying me that you can't change a simple checkmark on a control's runtime menu. I can trap it in the Menu Activation event as Michael suggested, and that works for detection, but I'd like to change states of the menu (even be able to change the text items displayed depending on what the user selected last). Here is an example of what I am trying to do, and how far I was able to get it using a kludge...

Sub Panel.vi (LV8.0.1)

Basically, I want to change the colors of the things the user "disables" from the right click menus available, then be able to change them back if they select it again. The checkmark would have been perfect for this, but I can't figure out how to "check" the selection when the user selection event is fired.

Is this impossible? Are there suggestions out there for how to do this a different way?

Thanks!

Link to comment

Michael,

Thanks for the example. However, it only gets me 75% there. Your example would work if you have two menu items that interact with each other (toggle back and forth). Its when you try and have them toggle the checkmark individually that you run into problems.

In your example, there are only two states possible: Option A checked or Option B checked. I need to have four states: both unchecked, Option A checked, Option B checked, or both checked. This is the crux of the problem since in order to change the state of these checkmarks, you need to have both the MenuRef and the selection of the user in the same event frame to know which item to check/uncheck.

Link to comment
  • 3 months later...

QUOTE(orko @ Feb 16 2007, 02:13 AM)

Hi all,

I've been beating my head against this for hours...so it's time to ask for help. :headbang:

I've created a run-time menu and saved it to disk for a numeric control with one selection item, let's say its named "foo" and is located in "menu1.rtm". I can then attach this menu to my numeric control and create an event structure handling the event: "foo: Shortcut Menu Selection (User)" to trap when someone selects this item from the menu. This works as desired.

My problem is, how can I check/uncheck the selection in the menu as I can do using the "Set Menu Item Info" menu primitives for application menus?? I don't see where I can get the MenuRef of the user rtm from within my event structure... I can only get the control reference, Item tag, Item path, and something called a "SubObj" (not at all sure what this is).

My goal is to perform one thing when the user "checks" the selection, and another when they "uncheck" it.

Thanks for any pointers!

I stumbled uppon allmost the same problem today: I need a reference to the runtime-shortcut menu of a control, to edit that menu programatically ...

If I have not missed something, there is no way to get a reference through the *normal* property-nodes. You can get a reference to the menu, if you use an event structure and the "Shortcut Menu Activation?" event, but this only works if you catch the event for one, single control. If you bundle more then one "Shortcut Menu Activation?" event in one case, you'll get no reference to the menu at all.

And here's where my problem starts: I've about 50 controls on my FP, and I need to catch at least 4 events on each control, two for Shortcut menu activation and Menu selection, the rest for drag and drop. If I can get the reference to the shortcut menu only if I create an event case for each control and it's sub-controls, in case that the control is a cluster, I'd end up with a huge event structure with lots of similar cases. I'm not very happy with this, so I'd be glad, if someone out there maybe knows a better way?

Link to comment
  • 1 year later...
  • 6 years later...

Now this is quite old and maybe it didn't work back then, but with LV 2013 there is no problem doing this...

https://lavag.org/files/file/265-falk-schneider/

I stumbled uppon allmost the same problem today: I need a reference to the runtime-shortcut menu of a control, to edit that menu programatically ...

If I have not missed something, there is no way to get a reference through the *normal* property-nodes. You can get a reference to the menu, if you use an event structure and the "Shortcut Menu Activation?" event, but this only works if you catch the event for one, single control. If you bundle more then one "Shortcut Menu Activation?" event in one case, you'll get no reference to the menu at all.

And here's where my problem starts: I've about 50 controls on my FP, and I need to catch at least 4 events on each control, two for Shortcut menu activation and Menu selection, the rest for drag and drop. If I can get the reference to the shortcut menu only if I create an event case for each control and it's sub-controls, in case that the control is a cluster, I'd end up with a huge event structure with lots of similar cases. I'm not very happy with this, so I'd be glad, if someone out there maybe knows a better way?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.