Don't generate any events from wxSpinCtrl and wxSpinCtrlDouble methods.
After the changes of r53758 wxMSW didn't generate any wxEVT_TEXT events but this was still the case for the generic version (and hence for wxSpinCtrlDouble under MSW too) and wasn't documented. Fix all versions to avoid sending events for programmatic actions, add unit tests checking this behaviour and document it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74631 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -117,9 +117,15 @@ protected:
|
||||
virtual void DoEnable(bool enable);
|
||||
#endif // __WXMSW__
|
||||
|
||||
enum SendEvent
|
||||
{
|
||||
SendEvent_None,
|
||||
SendEvent_Text
|
||||
};
|
||||
|
||||
// generic double valued functions
|
||||
double DoGetValue() const { return m_value; }
|
||||
bool DoSetValue(double val);
|
||||
bool DoSetValue(double val, SendEvent sendEvent);
|
||||
void DoSetRange(double min_val, double max_val);
|
||||
void DoSetIncrement(double inc);
|
||||
|
||||
@@ -129,7 +135,7 @@ protected:
|
||||
// can also change the text control if its value is invalid
|
||||
//
|
||||
// return true if our value has changed
|
||||
bool SyncSpinToText();
|
||||
bool SyncSpinToText(SendEvent sendEvent);
|
||||
|
||||
// Send the correct event type
|
||||
virtual void DoSendEvent() = 0;
|
||||
@@ -201,7 +207,7 @@ public:
|
||||
|
||||
bool ok = wxTextCtrl::Create(parent, id, value, pos, size, style,
|
||||
wxDefaultValidator, name);
|
||||
DoSetValue(initial);
|
||||
DoSetValue(initial, SendEvent_None);
|
||||
|
||||
return ok;
|
||||
}
|
||||
@@ -237,9 +243,20 @@ protected:
|
||||
return n;
|
||||
}
|
||||
|
||||
bool DoSetValue(double val)
|
||||
bool DoSetValue(double val, SendEvent sendEvent)
|
||||
{
|
||||
wxTextCtrl::SetValue(wxString::Format(m_format.c_str(), val));
|
||||
wxString str(wxString::Format(m_format, val));
|
||||
switch ( sendEvent )
|
||||
{
|
||||
case SendEvent_None:
|
||||
wxTextCtrl::ChangeValue(str);
|
||||
break;
|
||||
|
||||
case SendEvent_Text:
|
||||
wxTextCtrl::SetValue(str);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
void DoSetRange(double min_val, double max_val)
|
||||
@@ -305,7 +322,7 @@ public:
|
||||
// operations
|
||||
void SetValue(const wxString& value)
|
||||
{ wxSpinCtrlGenericBase::SetValue(value); }
|
||||
void SetValue( int value ) { DoSetValue(value); }
|
||||
void SetValue( int value ) { DoSetValue(value, SendEvent_None); }
|
||||
void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); }
|
||||
void SetIncrement(int inc) { DoSetIncrement(inc); }
|
||||
|
||||
@@ -381,7 +398,7 @@ public:
|
||||
// operations
|
||||
void SetValue(const wxString& value)
|
||||
{ wxSpinCtrlGenericBase::SetValue(value); }
|
||||
void SetValue(double value) { DoSetValue(value); }
|
||||
void SetValue(double value) { DoSetValue(value, SendEvent_None); }
|
||||
void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); }
|
||||
void SetIncrement(double inc) { DoSetIncrement(inc); }
|
||||
void SetDigits(unsigned digits);
|
||||
|
Reference in New Issue
Block a user