01-12-2011 05:17 AM
Hello,
i have two event-structures (struct1 and struct2) which are running at the same time parallel in a loop.
Currently there is an keydown-event in struct1, so when i press an ok-button then the corresponding event executes in struct1.
struct2 is used to execute menu-entries from a custom runtime-menue.
What i want to do is to select a menue-entry (which executes an event in struct2) and the from inside this event i want to trigger an event in struct1 (means simulate keypress ? ).
Is this possible?
Thanks for the help
Solved! Go to Solution.
01-12-2011 05:47 AM
Use the <Value Changed> Event for the ok button, not the keydown event.
Then in the second event structure, use the property Value(Signaling)of the ok button to trigger the Value Change Event.
Felix
01-12-2011 06:03 AM
OnlyOne,
You just need to have some user events to send an event from one structrue to the other:
Have also added a boolean user event to stop the top loop from the bottom.
Rgs,
Lucither.
01-12-2011 06:30 AM
Minor bug in Lucither's code:
* Make sure to call the Destroy user Event after the Unregister event.
You don't get any troubles these days, but LV 7.1. will crash if you don't do it in the right order.
Felix
01-12-2011 06:39 AM - edited 01-12-2011 06:40 AM
Thanks Felix,
I was actually unaware of that, Perhaps because i have only ever used 2009 i always get away with it. Will be the last time though
Have altered accordingly.
Rgs,
Lucither.
01-12-2011 06:55 AM
Other way round. Destroy after unregister. (Don't unregister the invalid Event).
Felix
01-12-2011 07:01 AM
HOW ABOUT NOW!!!!
Even monkeys learn
01-13-2011 08:35 AM
If I read this problem correctly, you are essentially trying to do the same thing from different events in different event structures. This type of problem is very common in UI based programs, since you often want to have the same action triggered by multiple events (e.g. button press, menu selection, keyboard shortcut). You may wish to consider a change in your basic architecture. Instead of splitting your code into two event structure loops, try splitting it into an event structure loop and a task handling loop. The event structure only processes events. At each event, it generates one or more tasks, which are passed to the task loop via queue. Traditionally, the task data would be an enum for the task name and a variant for the task data. You can find a discussion of this type of design here.
For new designs, I would recommend a task object (use LabVIEW classes). The task data type is the parent task object. The actual tasks will be child objects. This simplifies your top-level code quite a bit and makes it easily extensible without changing the top-level code.
If you need more information, let us know.