LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Slider control generates too many "value change" events

I have used a slider control (with digital control showing) for user input. Each time the value is changed by the user, the app makes certain computations before sending a command (TCP) to a cRIO chassis (that then implements other code). When the user drags the slider value around, it generates many value change events (captured by my event structure) very rapidly, which overwhelm the cRIO. I'd like to slow down the input changes; ideally I'd like to wait until the user releases the mouse. I do not see a way to do this. Can you help?

 

(Specifically, I would like to suspend value change events after the mouse button is pressed down. After the user releases the mouse, I would send the update once and re-enable "value change" detection. Yes, I could use dynamic registration for value change, but that is inadequate for 2 reasons. 1) I am already using it for another event within the event structure, and LV handles separate dynamic registrations poorly. 2) even if the dyn reg worked perfectly, the mouse-up event is not properly captured. See below. It is simpler to use a global boolean to enable/disable value change events rather than dynamic registration, but I have to know correctly when to re-enable.)

 

I see that there is a "Mouse Up" event that I can use, but it has only limited value because it only works if the user releases while over the control. If the user clicks the slider, then moves the mouse off the slider and then releases, the mouse-up never registers. I could register for "mouse up" for the pane, but what if the user moves off the window?

 

There is also the issue of "mouse leave." I considered this (in conjunction with mouse up), but even the combination is inadequate. The user can click on the slider, then move off the control. The mouse leave event would register, but the user still has control of the value, and can generate more "value change" events. (Remember the point of the mouse leave is to know when to re-enable value change detection.) I can't use the mouse leave event to re-enable value change events, because the user still has control of the slider, and can generate them as rapidly as my original problem.

 

Do you have any suggestions?

 

The lack of an event for user relinquishing control of a control seems a fundamental flaw. It's strange that mouse-up and mouse-leave are there, but not anything resembling relinquishing control.

 

Is it possible to use a property node or other LV tool to programmatically "kill" the user control of the slider? That is, is there any LV code that I can call when I detect "mouse leave" to force the user to relinquish the control, so that I know what the value is and the user has to re-engage (click on slider or enter value into numeric control) to change the control again?I tried key focus, but that was useless.

 

Thanks for any ideas!

0 Kudos
Message 1 of 15
(8,345 Views)

There is somewhere a whole thread about this 'issue' and a perfect workaround.

 

Now from the top of my head:

 

 

However using a slider to for this is not optimal (as you have noticed).

You could add a confimation dialo in the case the notifier has timed out (a certain time without value change events).

 

Ton

Message Edited by TonP on 01-05-2009 06:23 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!
0 Kudos
Message 2 of 15
(8,333 Views)

Two additional options:

  1. Compare the NewVal terminal to the control terminal and only perform your action if they are equal. This works because the control terminal holds the current value.
  2. Use the Value Change event to feed a short timeout value (e.g. 100 ms) into a shift register and wire the SR into the event structure's timeout terminal. In the timeout event, output -1 into the SR. As long as the VC event occurs, the timeout event will not. When the VC stops, the timeout event will occur and you can place your code there. This also works for other continuous events like Mouse Move or Panel Resize.

___________________
Try to take over the world!
Message 3 of 15
(8,302 Views)

LabVU_Dog wrote:

ideally I'd like to wait until the user releases the mouse.


Then why are you using 'value change' as your event? Use 'mouse up'. Simple enough.

Message Edited by Cory K on 01-05-2009 01:12 PM
Cory K
0 Kudos
Message 4 of 15
(8,297 Views)
*Edit, I didnt read the rest of your post explaining why mouse up wouldnt work.
Well, how about this. Once the user clicks on the control (aka mouse down event), if the user's mouse leaves the control area (aka mouse leave) just use the last value that the mouse was on before it left.

Message Edited by Cory K on 01-05-2009 01:28 PM
Cory K
0 Kudos
Message 5 of 15
(8,289 Views)

Cory K wrote:
*Edit, I didnt read the rest of your post explaining why mouse up wouldnt work.
Well, how about this. Once the user clicks on the control (aka mouse down event), if the user's mouse leaves the control area (aka mouse leave) just use the last value that the mouse was on before it left.


Here come the gory details of GUI design, a mouse that has left a slider (Mouse Leave) during a 'Mouse Down' they still can control the slider from everywhere on the screen (so even a 'Pane Leave' event isn't enough). The user still gets visual feedback that thy alter the slider value. If you decide to ignore that you will have quite some strange faces.

 

Ton

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!
0 Kudos
Message 6 of 15
(8,275 Views)

"Well, how about this. Once the user clicks on the control (aka mouse down event), if the user's mouse leaves the control area (aka mouse leave) just use the last value that the mouse was on before it left. "

 

That's what I wanted to do. The problem is that if the user is still holding down the mouse while leaving, he can still change the value of the control after leaving. I was hoping to use the mouse leave event to set the value and re-enable value change.

 

By the way, I need the value change detection so that I can detect when the user makes a change through the digital control.

 

Thanks!

0 Kudos
Message 7 of 15
(8,273 Views)

LabVU_Dog wrote:

By the way, I need the value change detection so that I can detect when the user makes a change through the digital control.


        Wow, I totally overlooked that.

Cory K
0 Kudos
Message 8 of 15
(8,269 Views)

Hi Ton,

 

I think I may be stuck using something like your technique with notifier. I'm using a QDSM architecture, so it should work. It just seems like a clunky work-around.

 

Also - with regard to "If you decide to ignore that you will have quite some strange faces.", I was trying to allow the user to control the slider as long as they are over the slider. Once they move off the slider, I force them to relinquish control (last value remains). This seems like it would be reasonable behavior.

 

Thanks!

0 Kudos
Message 9 of 15
(8,254 Views)

The easiest is to use a case structure in the "slide:value changed" event and compare the terminal value with the "newval" event terminal. Now only execute the bulk of the event code if they are the same. This way all stale events get shorted out.

 

Here's an old demo that shows the main idea and compares the behavior with/without selective updates.

 

 

Read more about it here.

 

Message Edited by altenbach on 01-05-2009 01:33 PM
Message 10 of 15
(8,251 Views)