cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX Slider can be set in between values

EmbDev
Senior

The range of the default Slider of TouchGFX can be configured by a min and max integer.
When the value has changed you can get a callback with the new value as an integer.

Still when moving the slider it is possible to set the location of the indicator in between two values, and then you get a callback with an integer (not the in between value)
Is it possible to force the indicator to the locations of the complete values?

1 ACCEPTED SOLUTION

Accepted Solutions

I am extremely sorry for my misunderstanding :downcast_face_with_sweat:

To set the indicator into the actual value, you can use setStopValueCallback() to make sure indicator will end up at the value that is returned by the callback. It would be something like this:

void MainView::setupScreen()
{
	horizontalSlider.setStopValueCallback(/*Your callback which calls changeSliderIndicatorValue */);
}

void MainView::changeSliderIndicatorValue(const Slider& src,int newVal)
{
	horizontalSlider.setValue(newVal);	
}

 

I hope this helps you

 

Mohammad MORADI
ST Software Developer | TouchGFX

View solution in original post

5 REPLIES 5

Hello @EmbDev ,

I'm very sorry but I didn't fully understand your question. Could you please first mention what you mean by the Slider of TouchGFX? Are you using ScrollabelContainer

And secondly, you want to set the value of the indicator to the value that is used in the callback?

Mohammad MORADI
ST Software Developer | TouchGFX

Hi Mohammad,

 

No I do not mean the ScrollableContainer, but the Slider (see link).

With the value property you can set a min and max integer range.
Let's assume I set it to min 1 and max 2.
In this case the leftmost indicator position means 1 and the rightmost location of the slider means 2.
When the indicator is set to a new location, I get a callback with a complete value (integer).
Still I am able to set the indicator exactly in the middle of the slider (visually). This location doesn't represent an actual value as it is in between values (the callback still returns the closest actual integer value).

So my question here is, can I force the indicator to move to a complete value location? (leftmost or rightmost in this example)

 

Slider with range 1-5, with the indicator in between 2 integers at 2.5:

EmbDev_0-1706267297324.png

Everything is integer based, but still I can set the indicator at a non-integer location.

I am extremely sorry for my misunderstanding :downcast_face_with_sweat:

To set the indicator into the actual value, you can use setStopValueCallback() to make sure indicator will end up at the value that is returned by the callback. It would be something like this:

void MainView::setupScreen()
{
	horizontalSlider.setStopValueCallback(/*Your callback which calls changeSliderIndicatorValue */);
}

void MainView::changeSliderIndicatorValue(const Slider& src,int newVal)
{
	horizontalSlider.setValue(newVal);	
}

 

I hope this helps you

 

Mohammad MORADI
ST Software Developer | TouchGFX

Found some time to look into this again. That is exactly what I was looking for, Thanks!

You are very welcome,
Glad to see I could help. 

Mohammad MORADI
ST Software Developer | TouchGFX