wxSlider with two thumbs Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

wxSlider with two thumbs

Post by mael15 »

hi,
is there such a thing as a wxSlider with two thumbs? i want to enable the user to set a range between two extreme int values. i.e. minimum = 10 and maximum = 1000, the user can set a range from 247 to 830.
can i create a slider with two thumbs?
maybe there is a better way?
thank you!
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxSlider with two thumbs

Post by doublemax »

Only supported under MSW, check the wxSL_SELRANGE style for wxSlider.
Use the source, Luke!
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: wxSlider with two thumbs

Post by eranon »

Hello, Outside of MSW, a kind of workaround there: https://stackoverflow.com/questions/297 ... e-on-linux

Where jordan9001 says:
You could have two sliders; one that will push the other so it remains lower, and one will remain higher?

I know it isn't the same thing, sorry, but it is an option. So when ever self.minSlider is moved, you bind wx.EVT_SCROLL with a function that will do something like:

Code: Select all

self.minSlider.Bind(wx.EVT_SCROLL, self.respondSliderChange())

def respondSliderChange(self):
    if self.minSlider.GetValue() >= self.maxSlider.GetValue():
        self.maxSlider.SetValue(self.minSlider.GetValue()+1)
and vice-versa for the maxSlider.

Besides that, you can look into creating a custom widget here.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: wxSlider with two thumbs

Post by mael15 »

doublemax wrote:Only supported under MSW, check the wxSL_SELRANGE style for wxSlider.
That seems perfect because my program is windows only. But the only change I see is a thicker slider bar?! No second thumb, so how can this select a range?!
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxSlider with two thumbs

Post by doublemax »

Sorry for putting you on the wrong track. After reading up on it, it turns out that this only enables you to display a visible range in the slider. But this can't be controlled by the user directly.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxSlider with two thumbs

Post by ONEEYEMAN »

Hi,
Why do you need 2 thumbs?
As a workaround you could try to have 2 slider controls - 1 for a minimum value and 1 for maximum value. This will be much better UI/UX than having 2 thumbs which will confuse people.

Thank you.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: wxSlider with two thumbs

Post by mael15 »

I want to enable the user to limit minimum and maximum for x and y coordinates, so I am using four sliders at the moment. These use a lot of space, I want to use as few controls as possible, and I think a two thumb slider would be very intuitive (at least for the x values with a horizontal slider).
left slider always stays at least one tick left of the right slider, the values are shows left and right beside the slider. I guess I will have to build a custom one.
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: wxSlider with two thumbs

Post by eranon »

In last resort, you could manage a double-thumb slider in a wxWebView (e.g. http://jsfiddle.net/abhitalks/a1f1k8d0/2/ and a lot of ways around searching on keywords like "javascript slider two thumbs") then acquire back the values at every change... But, of course, it's a little convoluted :wink:
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: wxSlider with two thumbs

Post by mael15 »

eranon wrote:In last resort, you could manage a double-thumb slider in a wxWebView (e.g. http://jsfiddle.net/abhitalks/a1f1k8d0/2/ and a lot of ways around searching on keywords like "javascript slider two thumbs") then acquire back the values at every change... But, of course, it's a little convoluted :wink:
interesting, thank you.
i am in the process of creating my own control. i have some classes using wxDragBitmap already, so it should work using these. unfortunately it seemed unpractical to inherit from wxSlider because it seems to be only a shell (is this the correct word?!) for os specific controls. i did not see an easy way to add a second thumb there.
if anyone needs the same thing and would like to have my source code, just send me a message or post here.
thanx everyone for your input!
User avatar
eranon
Can't get richer than this
Can't get richer than this
Posts: 867
Joined: Sun May 13, 2012 11:42 pm
Location: France
Contact:

Re: wxSlider with two thumbs

Post by eranon »

mael15 wrote:unfortunately it seemed unpractical to inherit from wxSlider because it seems to be only a shell (is this the correct word?!) for os specific controls. i did not see an easy way to add a second thumb there.
It's not an issue, it's a feature! It's one of the top quality of wxWidgets to rely on native controls... So, of course, by design, most of the time (unless when it's already possible with the OS's API itself), you can't change the native behavior of the controls.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
User avatar
ggbutcher
Earned a small fee
Earned a small fee
Posts: 12
Joined: Tue Aug 08, 2017 11:37 pm

Re: wxSlider with two thumbs

Post by ggbutcher »

I wrote one to implement a black/white point setter for an image processing program. You can find it here:

https://github.com/butcherg/rawproc/blob/master/src/

Look for myDoubleSlider.cpp, my DoubleSlider.h
Post Reply