From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure to increase a value while pressing a button

Solved!
Go to solution

I want to use an event structure to increase/ decrease a value.

It works with 1 Step.

But i want to increase the value continuously (200ms steps) while i press the button with the mouse. So the user could increase the value a little more comfortly. And when i stop pressing the button the value has to stop the increasing.

I don't get it work...

LV 8.2

0 Kudos
Message 1 of 15
(5,221 Views)

You would probably have to do this using either the timeout event or a user event. You would first trigger it off of the mouse down event on this button and in the timeout event continue to update the value until you get either a mouse up or mouse leave event.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 15
(5,211 Views)

Yea you could do it that way and use a shift register to pass a flag to the timeout event telling it the state of the mouse button (down or up) and have it use a case structure to take action or not.

---------------------------------
[will work for kudos]
0 Kudos
Message 3 of 15
(5,207 Views)

What are you having problems with? Is the event not triggering? Are you not understand the latching mechanism? Are you having problems with the timing? Are you using a numeric control? In this case the Value Change event should trigger whenever the up/down controls are used and held down (see first attachment). You may want to consider using 2 Boolean controls to give you better control. You can just use the Timout event of the event structure and set the mechanical action of the Boolean controls to continue to give you a True while the button is pressed (see second example). If you are still having problems then please post your code.

Download All
0 Kudos
Message 4 of 15
(5,203 Views)

The updown2.vi does what i want. Thanks !

But i have another Problem. I want to control about 30 Values. I have made a example vi with 3 values and the first one is my test object.

When i have 30 values, the timeout event becomes a little big...

Is it not possible with the mouse down or button pressed event ? I tested it in value 1 but the mouse down only calls once and so the value only gets one higher.

Or put a loop in it, which increases the value and detects mouse up to end the loop? I've tested it, but i can't get it work (see value 2). The end of the loop is the problem...

 

0 Kudos
Message 5 of 15
(5,172 Views)

I want to use it for a user interface with a touchpanel. So that the user could control the values with a fingertip. And when he presses the button long down it has to automatically increase. 

0 Kudos
Message 6 of 15
(5,166 Views)
Solution
Accepted by topic author Ralph.D

I got it !

Thanks for all help. I've got the loop ending. The problem was that the event structure has to allow the frontpanel access, so that the button could release.

See attached vi !

0 Kudos
Message 7 of 15
(5,156 Views)

You are doing this still way too complicated. Your code is not very scaleable, because it will be gigantic once you e.g. have 20 such buttons. There is way too much hidden code, such as all these stacked sequences and inner loops. Very convoluted. Lots of duplicate code. You have controls as indicators, countless unneeded local variables, etc.

 

All you need is one loop, two event cases, and a small bit of code for any number of buttons.

 

Try this. See if it makes sense. (LabVIEW 8.2) 😄

 

(Another idea would be to wrap the buttons and the slide indicator into an x-control. Try it.)

 

 

Message 8 of 15
(5,147 Views)

Hi Ralph,

 

Have posted another way to go. Might be of some interest to you. I have made a subvi that you can simply duplicate for every control you want to add the increment/decrement feature too.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 9 of 15
(5,145 Views)

Sorry, didnt realise you had 8.2

 

Is re-attached in 8.2

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 10 of 15
(5,137 Views)