LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert a mouse down coordinate to a slider value (using mouse down event on the slider) is it possible?!

When you click on the housing of a slide control, the slide jumps to that position. If you have multiple slides on a slide control, the last clicked on (or active slider) will jump to that position.

 

I'm trying to use a slide control to show/control a windowed region of a waveform. E.g. I have a horizontal slider underneath a waveform graph. The slider's scale range is wide than the graph's scale range, and I then have two sliders, slider 0 corresponds to the lower limit of the graph's scale and slider 1 to the upper limit. By setting slide 0 to have no fill and slide 1 to fill to the value below, I can "highlight" the range on the slider which corresponds to the range displayed in the graph.

 

Using events and the like, I have configured a system now which, when I drage the lower slider "shifts" the window (i.e. the width of the window stays fixed but the limits shift). If I drag the upper slide (slide 1) the lower limit is fixed and I adjust the width (hopefully you're with me so far!).

 

Now, for the problem. If the user adjusts the upper slider to set the desired window width, and then some time later goes to drag the lower slide but misses and clicks on the housing below slide 0, slide 1 (the still active slider) will jump to below slide 0 and break things (since then calculations on the sliders to get start and width are back to front). Similarly the opposite can happen if the user adjusts the lower slider then clicks beyond the upper one. I was hoping that i could use a mouse-down filter event to discard any clicks which are outside of the slider range (or possibly to quickly switch the active slider to be the one nearest the click) BUT I can't seem to find a reliable way to convert the mouse down co-ordinate to a slider value... I have managed to kind of cobble something together using the housing size property and the scale bounding rectangle (one or both of which require scripting...). But there's an offset between the two which is a pain as I can't be sure its constant, or even symmetric (i.e. I cant be sure that the housing and scale share the same centre...). I also have to then deal with whether slider scale has been flipped etc etc.

 

Surely LabView itself is converting the co-ordinate of the click to a value on the slide so why isn't there a way for me to access it?! I'd have thought the underlying functionality cant be much different to getting a plot value from a mouse co-ordinate like you can do with an invoke node on a graph control, so its frustrating that I can't find a clean way to do it. 

 

So, after all that, has anyone else tried to do anything similar in the past - am I missing a trick somewhere or do I just have to try to kludge it?

 

Thanks in advance, sorry for the rather complicated post, hopefully its vaguely clear!

 

Thanks

 

Paul

0 Kudos
Message 1 of 3
(3,135 Views)

Hi Psmorris,

 

The slide runner has an active area which can be changed. Also the fill area of the slide changes when you change the size of the slide. Since there is no straightforward way to find out the coordinates of the individual parts of the slide, infering/setting the value of the slide based on the coordinates of the mouse click is not reliable. I would reccomned you to use a radio button to set the active slide of your slide control. Though it is going to take a couple of extra clicks for the user, you can be assured that it is dependable and works.

 

Thanks and Regards,

Thanks and Regards,
Supreeth.K

0 Kudos
Message 2 of 3
(2,988 Views)

Thanks for the response, I have managed (using the code attached in the snippet attached) to get a reasonable estimate of the value of the slider control where the mouse down event occured. All of the inputs come from either a property node of the slider control or the mouse co-ordinates from the event structure. I can use that to then programatically set the active slider (another property node) to be the one closest to that value before letting labview handle the slider value change event triggered by the mouse down.

 

Its just a shame that, at some level, labview must be converting the mouse click position to a value in the slider, but I can access the results anywhere with an invoke or property node.

 

Ho hum.

 

Thanks

 

0 Kudos
Message 3 of 3
(2,978 Views)