01-05-2009 11:02 AM
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!
01-05-2009 11:21 AM - edited 01-05-2009 11:23 AM
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
01-05-2009 12:45 PM
Two additional options:
01-05-2009 01:09 PM - edited 01-05-2009 01:12 PM
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.
01-05-2009 01:23 PM - edited 01-05-2009 01:28 PM
01-05-2009 01:50 PM
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
01-05-2009 01:57 PM
"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!
01-05-2009 02:01 PM
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.
01-05-2009 03:20 PM
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!
01-05-2009 03:32 PM - edited 01-05-2009 03:33 PM
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.