X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/18e45a88f68d66e1980e0bda8817dd3fb4f18c18..6ac636dd07f8a506ef940f07468e5baf07cfc97f:/src/generic/spinctlg.cpp diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index 70a58db535..853b967500 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -338,13 +338,7 @@ void wxSpinCtrlGenericBase::OnSpinButton(wxSpinEvent& event) if (((spin_value >= 0) && (m_spin_value >= 0)) || ((spin_value <= 0) && (m_spin_value <= 0))) step *= abs(spin_value - m_spin_value); - double value = m_value + step*m_increment; - - // Check for over/underflow wrapping around if necessary - if (value < m_min) - value = HasFlag(wxSP_WRAP) ? m_max : m_min; - if (value > m_max) - value = HasFlag(wxSP_WRAP) ? m_min : m_max; + double value = AdjustToFitInRange(m_value + step*m_increment); // Ignore the edges when it wraps since the up/down event may be opposite // They are in GTK and Mac @@ -356,7 +350,7 @@ void wxSpinCtrlGenericBase::OnSpinButton(wxSpinEvent& event) m_spin_value = spin_value; - if (InRange(value) && DoSetValue(value)) + if ( DoSetValue(value) ) DoSendEvent(); } @@ -369,6 +363,12 @@ void wxSpinCtrlGenericBase::OnTextEnter(wxCommandEvent& event) void wxSpinCtrlGenericBase::OnTextChar(wxKeyEvent& event) { + if ( !HasFlag(wxSP_ARROW_KEYS) ) + { + event.Skip(); + return; + } + double value = m_value; switch ( event.GetKeyCode() ) { @@ -393,6 +393,8 @@ void wxSpinCtrlGenericBase::OnTextChar(wxKeyEvent& event) return; } + value = AdjustToFitInRange(value); + if ( m_textCtrl && m_textCtrl->IsModified() ) SyncSpinToText(); @@ -483,6 +485,16 @@ bool wxSpinCtrlGenericBase::DoSetValue(double val) return false; } +double wxSpinCtrlGenericBase::AdjustToFitInRange(double value) const +{ + if (value < m_min) + value = HasFlag(wxSP_WRAP) ? m_max : m_min; + if (value > m_max) + value = HasFlag(wxSP_WRAP) ? m_min : m_max; + + return value; +} + void wxSpinCtrlGenericBase::DoSetRange(double min, double max) { m_min = min;