LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to fire a menu item programically

I am using an event structure to capture events from my custom run-time menu. However I would like to call the same code from one of those custom menu items progamically. Is there a way to dynamically fire a menu click so that the event structure will see it as an user event?

I am fimilar with user events and have used them in this code, but I don't want to register a seperate user event when I already have the code registered in the Menu Selection event.

Does this make sense enough?


Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 1 of 11
(2,786 Views)

Why don't you put your code in a sub vi. So you can call it from everywhere.

I don't know a way to trigger that event.

0 Kudos
Message 2 of 11
(2,780 Views)

Hi, Doug,

I don't thisnk that this possible easily. Of course, you can simulate key presses, but this is not good way.
What you can do is — you can build simple state machine, where you will handle menu items, and this state machine can be also controlled externally, so you will call the same code from different places. For me such design pattern useful when I need to handle the same events from menu and from "toolbar". Or simple use SubVIs as mentioned above.

best regards,
Andrey.

 

0 Kudos
Message 3 of 11
(2,775 Views)


@DougFerguson wrote:
I am using an event structure to capture events from my custom run-time menu. However I would like to call the same code from one of those custom menu items progamically. Is there a way to dynamically fire a menu click so that the event structure will see it as an user event?

Does this make sense enough?



Yes, it makes sense and Yes, it is possible:
However I always try to forward all these possibilities to one User event. But that's another story.

It's a private method, read here how to access those.

The tags are located here


Message Edited by TonP on 07-26-2008 12:30 PM
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 4 of 11
(2,751 Views)
Bravo, TonP! I spend quarter hour for looking for the according property node (even private), but haven't found... But you done. In some cases this may be useful. Thanks. Andrey.


Message Edited by Andrey Dmitriev on 07-26-2008 11:12 PM
0 Kudos
Message 5 of 11
(2,722 Views)
Wow. That might be the coolest thing I have ever seen...


Thanks
Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 6 of 11
(2,664 Views)
Okay after looking at my code, I think I want to move all my action code from inside event handler to a SUB vi that is called by the event handler and executed outside the event handler. However I have several property nodes to front panel items. How can I reference front panel objects inside a sub VI without creating a bunch of references for each ietm and pssing them to the subVI?
Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 7 of 11
(2,634 Views)
Why don't you just have your menu item trigger a Value (SGN) node, and keep the code in your event structure?
0 Kudos
Message 8 of 11
(2,619 Views)
I've done that with some of my event cases and it works well. But the event in this case is a menu selection. Right now I have 35 events and 24 menu selections. Its getting increasingly difficult to call the same code without getting creative. So I am going to move some of the most often called code out into a subVI and have the event handler handle the data to be passed into the subVI.
Doug Ferguson

www.southerndaqsolutions.com
0 Kudos
Message 9 of 11
(2,613 Views)

Pass all the references to global variables. One of a few times, i use globals.

So you can use them from everywhere

0 Kudos
Message 10 of 11
(2,597 Views)