Validators for wxSpinCtrlDouble

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
nomadwolf
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Jul 15, 2022 4:53 am

Validators for wxSpinCtrlDouble

Post by nomadwolf »

What is the proper validator to use for wxSpinCtrlDouble? wxGenericValidator seems to skip that control, and since the control doesn't derive from a textCtrl, wxFloatingPointValidator<> also doesn't work.

Is not including it in wxGenericValidator intentional or an oversight?
User avatar
doublemax
Moderator
Moderator
Posts: 19115
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Validators for wxSpinCtrlDouble

Post by doublemax »

Looking into the source code, wxSpinCtrlDouble does set a wxFloatingPointValidator by default.

What is not working for you?
Use the source, Luke!
nomadwolf
In need of some credit
In need of some credit
Posts: 9
Joined: Fri Jul 15, 2022 4:53 am

Re: Validators for wxSpinCtrlDouble

Post by nomadwolf »

here's the snippet:

Code: Select all

minFontSizeCtrl = new wxSpinCtrlDouble(labelBox, wxID_ANY, wxString(),
                            wxDefaultPosition, wxDefaultSize,
                            wxSP_ARROW_KEYS | wxALIGN_RIGHT, 0, 20,
                            m_doubleData, 0.1);
minFontSizeCtrl->SetDigits(1);
minFontSizeCtrl->SetValidator(wxFloatingPointValidator(&m_doubleData));
When I hit the SetValidator() call, I get the Assert Failure:
""Assert Failure"" failed in wxNumValidatorBase::SetWindow(): Can only be used with wxTextCtrl or wxComboBox.
Stepping through the code, I do se the wxFloatingPointValidator used in DoSetDigits(), but that is set on m_textCtrl. And I don't see any way to access it.
Post Reply