Search code examples
sliderlabview

LabVIEW disabled Slider is enabled


I have a large problem disabling a slider in LabVIEW. Here is my minimal example:

I have a simple Slider, which is disabled and grayed out if the value is higher than 5. Otherwise the Slider is enabled.

enter image description here

If I drag the slider higher than 5, the Slider gets grayed out. But I am still able to move the slider around and change the value. Only after I dropped the Slider, the Slider is disabled to use.

In my opinion, this is a large bug of LabVIEW. Is there any way to disable the Slider correct during drag?

Thank you for your answers!

Additional information: Like I said, the snippet is only my minimal example to show the basic problem. In my application the following is happening:

I have s statemachine with a state that enables the Slider and a state that disables my Slider. The state can change every moment, so it´s possible, the user is using the slider at the moment of statechange --> moment of disabling. At this moment the slider should be disabled (it only gets grayed out) directly ... not after releasing it. So limiting the maximum is not real target. I want to prohibit all slider actions for a user.

"Link to question asked on NI Discussion Forums"


Solution

  • As suggested by Alexander_Sobolev on the NI forum (but I promise I thought of it independently!), you can end the slider drag by generating a mouse up event. On Windows you can do this with Simulate Mouse.vi from the NI site, which calls mouse_event from user32.dll:

    VI snippet showing use of Simulate Mouse.vi

    Note that one of that VI's mouse position inputs is erroneously marked as 'Required'; I fixed that before creating the code above.

    I do think this is a UI technique that should only be used if it's really justified by the requirements of the system, and if the users will understand why it works like that; otherwise it could make for a frustrating and annoying user experience. I don't think it's a bug, rather a design decision, because the opposite behaviour could be equally undesired in other circumstances.