Fix resetting text override when manually entering the text
The entered text wasn't taken into account, as the override was still used when its numeric value was retrieved by GtkSpinButton using our "input" handler, so reset the override now as soon as we get "changed" signal.
This commit is contained in:
@@ -102,10 +102,17 @@ protected:
|
||||
// override this and return true.
|
||||
virtual bool UseGTKStyleBase() const wxOVERRIDE { return true; }
|
||||
|
||||
// Set or reset m_textOverride.
|
||||
// Set m_textOverride to use the given text instead of the numeric value.
|
||||
void GTKSetTextOverride(const wxString& text);
|
||||
|
||||
// Reset the override and changing the value to correspond to the
|
||||
// previously overridden numeric value.
|
||||
void GTKResetTextOverride();
|
||||
|
||||
// Just reset the override, without touching the value, returning true if
|
||||
// we did it. In most cases, the function above should be used instead.
|
||||
bool GTKResetTextOverrideOnly();
|
||||
|
||||
private:
|
||||
// This function does _not_ take into account m_textOverride, so it is
|
||||
// private and normally shouldn't be used -- use DoGetValue() instead.
|
||||
|
@@ -176,14 +176,22 @@ void wxSpinCtrlGTKBase::GTKSetTextOverride(const wxString& text)
|
||||
m_textOverride->m_text = text;
|
||||
}
|
||||
|
||||
void wxSpinCtrlGTKBase::GTKResetTextOverride()
|
||||
bool wxSpinCtrlGTKBase::GTKResetTextOverrideOnly()
|
||||
{
|
||||
if ( !m_textOverride )
|
||||
return;
|
||||
return false;
|
||||
|
||||
delete m_textOverride;
|
||||
m_textOverride = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxSpinCtrlGTKBase::GTKResetTextOverride()
|
||||
{
|
||||
if ( !GTKResetTextOverrideOnly() )
|
||||
return;
|
||||
|
||||
// Update the text part to reflect the numeric value now that we don't
|
||||
// override it any longer, otherwise we'd keep showing the old one because
|
||||
// the text is updated by GTK before "value" is generated.
|
||||
@@ -524,7 +532,10 @@ bool wxSpinCtrlGTKBase::GTKOutput(wxString* text) const
|
||||
|
||||
void wxSpinCtrlGTKBase::GTKTextChanged()
|
||||
{
|
||||
GTKResetTextOverride();
|
||||
// We can't use GTKResetTextOverride() itself here because it would also
|
||||
// reset the value and we do not want this to happen -- the value is being
|
||||
// changed to correspond to the new text.
|
||||
GTKResetTextOverrideOnly();
|
||||
|
||||
wxCommandEvent event( wxEVT_TEXT, GetId() );
|
||||
event.SetEventObject( this );
|
||||
|
Reference in New Issue
Block a user