How to replicate "lv_slider_set_knob_in" from previous versions?


It used to be possible to make the slider knob stay within the bounds of the slider when at min/max with lv_slider_set_knob_in.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

lv_slider_set_knob_in functionality or something similar in v7

What have you tried so far?

Not sure what to try, the functionality seems to have been removed.

Code to reproduce


Screenshot and/or video


According to the docs setting padding on the knob will make it larger.

Not trying to make the knob larger, but rather have it stop earlier when at min/max values, so that knob doesn’t extend beyond the slider:

That is, I want the left part of the knob to not extend further than the left of the slider when at the minimum (and right part for the right side of the slider). This is what the old lv_slider_set_knob_in did, right?

If you try to pad LV_SLIDER_PART_BG you can prevent the knob from going outside the slider, but it also changes the drawing of the slider:

I’ve removed this feature because it was a hacky solution to make possible to derive lv_switch from lv_slider. As now lv_switch is derived from lv_bar this feature is not required. I was considering to keep it but as sliders on other platforms (web, desktop) doesn’t use the “knob-in” positioning (at least I never saw it) I decided to remove it to keep LVGL free from non-standard features and make the code cleaner.

Unfortunately, I don’t know a direct replacement for it. :frowning:

1 Like