added NormalizeValue() which can be used to ensure that the control value is in range

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40540 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-08-10 00:43:35 +00:00
parent e63f19ba93
commit 5ec60151bf
2 changed files with 5 additions and 2 deletions

View File

@@ -60,6 +60,9 @@ public:
protected: protected:
virtual wxSize DoGetBestSize() const; virtual wxSize DoGetBestSize() const;
// ensure that the control displays a value in the current range
void NormalizeValue() { SetValue(GetValue()); }
private: private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSpinButton) DECLARE_DYNAMIC_CLASS_NO_COPY(wxSpinButton)
}; };

View File

@@ -253,8 +253,8 @@ void wxSpinCtrl::OnChar(wxKeyEvent& event)
void wxSpinCtrl::OnKillFocus(wxFocusEvent& event) void wxSpinCtrl::OnKillFocus(wxFocusEvent& event)
{ {
// ensure that the value is shown correctly // ensure that a correct value is shown by the control
SetValue(GetValue()) ; NormalizeValue();
event.Skip(); event.Skip();
} }