LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Added menu items programmatically - but how do I get a response

Hi everyone. I hope the thread title is not too confusing, but I couldn't find a better description.

The problem is as follows:

I am currently developing a Top Level App which uses events to handle menu clicks and more. Now during runtime, I would like to add a list of filenames programmatically to a menu item (Open). Basically I should get the following:
File
  New
  Open
    Filename 1
    Filename 2
  Save

I could already achieve this using the Insert Menu Items VI. Works perfectly.
Now I want to be informed when one of these filenames has been clicked. Therefore I should give Filename1, Filename2 a "item Tag" Property. As I found out, this is absolutely unique, so each different filename throws some event. To be honest, I am going to handle all of these events the same way, therefore I'd like to write a single "frame" which then works with the given file.

So my question is: Which is the right way to achieve this?
Idea 1: Should I use the "Default" Menu Item Selected Handler and question which menu item was pressed manually? But then - which item Tag should I give, since they can change

Thank you
0 Kudos
Message 1 of 6
(3,326 Views)
Just had another idea ...

Could I use the Default behaviour for the menu and then decide based upon the Item Path property, if it starts with File - Open and then take actions based on that?

Is that the correct way to do it?


0 Kudos
Message 2 of 6
(3,319 Views)
Hi Thomas,
the item tag is independent from the item name (which is shown in the menu). So give it "File_01", "File_02" and so on. Then you can extract the number from the tag and hold your own list of Filenames or you get the name from the Item-name.
If you need more details, ask.
Greets, Dave
Greets, Dave
Message 3 of 6
(3,319 Views)
Hmmm .. adding a number ... The problem is I need the filename anyway, so it's no problem if the filename is either in item Tag or Item Name.

But your advice gives me another idea. I could display metadata from inside the file and "hide" the filename in the back. Maybe that would make the program more clear. Thanks for your input - I think I'll use that idea of yours - but for another purpose 🙂
0 Kudos
Message 4 of 6
(3,317 Views)
Hi Thomas

I would implement it in the way you suggested. Use the "Default" case for the File > Open > File XY, and handle the other menu items like Save (with fixed tags) in special cases.
And like Dave said, keep an internal list which assigns the menu tags to the file names.

Regards, Daniel


Message 5 of 6
(3,313 Views)
Ok, that's what I was thinking of. Glad to hear I'm not completely wrong - and yes - I'll hold that list, because that gives me some damn good idea 🙂

Thanks to you both.
0 Kudos
Message 6 of 6
(3,310 Views)