Getting wxSpinCtrlDouble to work ...

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Getting wxSpinCtrlDouble to work ...

Post by Caofi »

So elsewhere I used wxSpinCtrl, and it worked as expected. But for a new dialog, I need non integer values and Googling found wxSpinCtrlDouble.
But it is not working as I expected:

Code: Select all

m_drop_threshold_ctrl = new wxSpinCtrlDouble(this, wxID_ANY, "0.5");
m_drop_threshold_ctrl->SetIncrement(0.05);
m_drop_threshold_ctrl->SetValue(0.5);
I wanted a default value of 0.5, with increments of 0.05. But instead it only displays 0 or 1.
Where am I going wrong?

Here is the class reference: https://docs.wxwidgets.org/3.0/classwx_ ... ouble.html
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Getting wxSpinCtrlDouble to work ...

Post by doublemax »

Did you call SetDigits like mentioned in the documentaion for SetIncrement?
Use the source, Luke!
Caofi
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Dec 01, 2021 12:47 am

Re: Getting wxSpinCtrlDouble to work ...

Post by Caofi »

Hahaha... thanks! Once again, it shows I can't read the docs, and you solve it with a small tweak.

My code is now:

Code: Select all

m_drop_threshold_ctrl = new wxSpinCtrlDouble(this, wxID_ANY, "0.5");
m_drop_threshold_ctrl->SetRange(0, 1);
m_drop_threshold_ctrl->SetDigits(2);
m_drop_threshold_ctrl->SetIncrement(0.05);
m_drop_threshold_ctrl->SetValue(0.5);
Thanks again!
Post Reply