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.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Double slider

Solved!
Go to solution

Hello, hello,

what's the best way to do a double slider to select a range of values ?

By that I mean you have a slider with MIN / MAX values, and two cursors, a LOW one and a HIGH one. The first one being obviously always lower than the other one (strict or not).

 

I've tried a simple way with 2 separate sliders (named LOW and HIGH) and to set the MIN of the HIGH one to the current value of the LOW one, and to set the MAX of the LOW one to the current value of the HIGH one. But since their min/max change, they kind of change dynamically in annoying ways.

 

Do you have better suggestions ?

0 Kudos
Message 1 of 6
(3,559 Views)

During the night I thought about using a graph without border nor plots, but with 2 cursors. The result isn't fancy but it's simple and performs as expected for a range selector. Any other suggestions ?

0 Kudos
Message 2 of 6
(3,530 Views)
Solution
Accepted by topic author gdargaud

Hi,

What about just having two sliders, one for your min and one for your max value. Both sliders would have the same range but you would take account for the values programmatically. You would check to see if the max value set is bigger than the min value in your code. 

Is this not an option for you?

 

Best Regards,

T. Le
Vision Product Support Engineer
National Instruments
Message 3 of 6
(3,515 Views)

You mean not setting MIN/MAX of one with the current value of the other, but simply catching VAL_CHANGED and not letting the value change if it goes over/under ? Yeah, maybe that'd work.

0 Kudos
Message 4 of 6
(3,511 Views)

Yes exactly.

T. Le
Vision Product Support Engineer
National Instruments
0 Kudos
Message 5 of 6
(3,508 Views)

I've used the following callback for the 2 sliders and it is more intuitive to push the other slider than to block the one being pushed when reaching the min/max:

case EVENT_VAL_CHANGED:
case EVENT_COMMIT:
	if (control==PNL_SLIDE_LOW) {
		GetCtrlVal(panel, control,        &ITL);
		GetCtrlVal(panel, PNL_SLIDE_HIGH, &ITH);
//		if (ITL>ITH) SetCtrlVal(panel, control, ITL=ITH);		// Blocks
		if (ITL>ITH) SetCtrlVal(panel, PNL_SLIDE_HIGH, ITH=ITL);// Push
	} else {
		GetCtrlVal(panel, control,        &ITH);
		GetCtrlVal(panel, PNL_SLIDE_LOW , &ITL);
//		if (ITL>ITH) SetCtrlVal(panel, control, ITH=ITL);		// Blocks
		if (ITL>ITH) SetCtrlVal(panel, PNL_SLIDE_LOW, ITL=ITH);	// Push
	}
	if (event==EVENT_VAL_CHANGED) break;
	// Do something with ITL and ITH
0 Kudos
Message 6 of 6
(3,471 Views)