LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger events from inside an event to another event-structure

Solved!
Go to solution

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

0 Kudos
Message 1 of 8
(5,947 Views)
Solution
Accepted by OnlyOne

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

 

Message 2 of 8
(5,936 Views)

OnlyOne,

 

You just need to have some user events to send an event from one structrue to the other:

 

user events.png

 

Have also added a boolean user event to stop the top loop from the bottom.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 3 of 8
(5,930 Views)

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. Smiley Wink

 

Felix

Message 4 of 8
(5,919 Views)

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 Smiley Tongue

 

user events.png

 

Have altered accordingly.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 5 of 8
(5,913 Views)

Other way round. Destroy after unregister. (Don't unregister the invalid Event). Smiley Wink

 

Felix

0 Kudos
Message 6 of 8
(5,905 Views)

user events.png

 

HOW ABOUT NOW!!!! Smiley Mad

 

Even monkeys learn Smiley Very Happy

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 7 of 8
(5,899 Views)

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.

Message 8 of 8
(5,857 Views)