LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the same button for multiple event case

Hi experts,

 

May I know how to use the same button for multiple event cases? For example, I have a "enter" button that is used for several different purposes.

 

Is there a solution for this? Thank you in advance

0 Kudos
Message 1 of 11
(309 Views)

Hi Timothy,

 


@timothysilverman wrote:

May I know how to use the same button for multiple event cases? For example, I have a "enter" button that is used for several different purposes.

Is there a solution for this?


You can not assign the same button to several event cases.

But you can implement a statemachine or (event-driven) QMH to handle the button event as needed…

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 2 of 11
(295 Views)

Hi GerdW,

 

Are there any examples which I can refer to?

Thank you!

 

0 Kudos
Message 3 of 11
(291 Views)

Hi Timothy,

 

LabVIEW comes with a lot of examples in its example finder and in the "New projects" dialog.

There are examples for statemachines and QMH (queued message handlers)…

Best regards,
GerdW


using LV2020 on Win8.1+cRIO
0 Kudos
Message 4 of 11
(284 Views)

@timothysilverman wrote:

May I know how to use the same button for multiple event cases? For example, I have a "enter" button that is used for several different purposes.

 


If enter is pressed, what determines the purpose? How does the code know? Is there e.g. an enum that indicates state?

 

Why not use a single event case containing a case structure with one case for each "purpose", whatever that means. State?

 

Can you take a step back and tell us what problem you are trying to solve, not how you are trying to solve it. I am sure there are much better solutions.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 11
(241 Views)

Hi altenbach,

 

The problem I'm trying to solve is to have a button to handle several event structures. Just like I mentioned before, the "enter" button will be needed to execute several event structures, and I'm wondering how I can make it work. 

 

For example, 

1. I need the "enter" button to accept the user input and verify the user.

2. I need the "enter" button to also handle the mathematic calculation that the user enters.

 

I hope there is a way to do this, thank you

 

Best regards,

timothysilverman

0 Kudos
Message 6 of 11
(200 Views)

Hi Timothy,

 

there still is a lot of "how" and not so much "what"…

 

Why are there "several event structures" in your VI? There should be only one!

(Well, there can be more than one, but as you are asking basic questions about using event structures I guess you are not experienced enough to use several event structures within one VI.)

 


@timothysilverman wrote:

For example, 

1. I need the "enter" button to accept the user input and verify the user.

2. I need the "enter" button to also handle the mathematic calculation that the user enters.


  1. Why do you need an event case handling the <Enter> key? Why don't you use a ValueChange event of your user input?
  2. Here the same applies: why not handling ValueChange events for user input?
Best regards,
GerdW


using LV2020 on Win8.1+cRIO
Message 7 of 11
(195 Views)

Usually if i need several events executed by one action, i daisy-chain hidden controls, which then get updated by event cases.

 

I think i've only done what you need once tho, because events are usually separate things (so it's PITA to trigger them all) and it just so happened that i needed them triggered sequentially.

 

What GerdW suggested seems more reasonable.

0 Kudos
Message 8 of 11
(190 Views)

Hi GerdW,

 

Indeed I am new to LabView.

I will try to apply the ValueChange to my vi

 

Thank you

0 Kudos
Message 9 of 11
(187 Views)

Hi Timothy,

 

As has already been suggested, the ValueChange events for each input might be what you're looking for (and they're certainly likely to be easier to use).

 

However, I'm curious about your use of the term Enter. Do you mean you have a (LabVIEW) button with the text "Enter" or are you talking about the keyboard enter/return key?

 

The latter can be integrated with an Event Structure using the Key Down event in the <This VI> category.

You could then use the VKey output to determine if Enter/Return was pressed, and then evaluate what to do based on the FocusObj, maybe (if you have the focus in a control that you're entering data for).

 

See the example here (note that the "boolean" input doesn't work in a useful way, because it can't have easily input focus - although you can bind it to a keyboard shortcut and then give it focus...)

eventFocusEnter.png

 

For this example, I'd definitely pick the ValueChange event instead, which would make it much easier to handle the appropriate datatypes. But maybe your use case has some features which you haven't described fully here, and those could maybe make this useful?

 

 


GCentralI'm attending the GLA Summit!
0 Kudos
Message 10 of 11
(172 Views)