Block all events in wxSpinCtrl::SetValue etc.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
e83e16de9e
commit
0bf36922c8
@ -55,8 +55,8 @@ public:
|
|||||||
// implementation
|
// implementation
|
||||||
void OnChar( wxKeyEvent &event );
|
void OnChar( wxKeyEvent &event );
|
||||||
|
|
||||||
void GtkDisableEvents();
|
void GtkDisableEvents() const;
|
||||||
void GtkEnableEvents();
|
void GtkEnableEvents() const;
|
||||||
|
|
||||||
int m_pos;
|
int m_pos;
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
|
gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget),
|
||||||
(int)(m_windowStyle & wxSP_WRAP) );
|
(int)(m_windowStyle & wxSP_WRAP) );
|
||||||
|
|
||||||
g_signal_connect(m_widget, "value_changed", G_CALLBACK(gtk_value_changed), this);
|
g_signal_connect_after(m_widget, "value_changed", G_CALLBACK(gtk_value_changed), this);
|
||||||
g_signal_connect(m_widget, "changed", G_CALLBACK(gtk_changed), this);
|
g_signal_connect_after(m_widget, "changed", G_CALLBACK(gtk_changed), this);
|
||||||
|
|
||||||
m_parent->DoAddChild( this );
|
m_parent->DoAddChild( this );
|
||||||
|
|
||||||
@ -149,9 +149,9 @@ int wxSpinCtrl::GetValue() const
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );
|
wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") );
|
||||||
|
|
||||||
wx_const_cast(wxSpinCtrl*, this)->BlockScrollEvent();
|
GtkDisableEvents();
|
||||||
gtk_spin_button_update( GTK_SPIN_BUTTON(m_widget) );
|
gtk_spin_button_update( GTK_SPIN_BUTTON(m_widget) );
|
||||||
wx_const_cast(wxSpinCtrl*, this)->UnblockScrollEvent();
|
GtkEnableEvents();
|
||||||
|
|
||||||
return m_pos;
|
return m_pos;
|
||||||
}
|
}
|
||||||
@ -169,9 +169,9 @@ void wxSpinCtrl::SetValue( const wxString& value )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// invalid number - set text as is (wxMSW compatible)
|
// invalid number - set text as is (wxMSW compatible)
|
||||||
BlockScrollEvent();
|
GtkDisableEvents();
|
||||||
gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) );
|
gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) );
|
||||||
UnblockScrollEvent();
|
GtkEnableEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,9 +179,9 @@ void wxSpinCtrl::SetValue( int value )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||||
|
|
||||||
BlockScrollEvent();
|
GtkDisableEvents();
|
||||||
gtk_spin_button_set_value((GtkSpinButton*)m_widget, value);
|
gtk_spin_button_set_value((GtkSpinButton*)m_widget, value);
|
||||||
UnblockScrollEvent();
|
GtkEnableEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinCtrl::SetSelection(long from, long to)
|
void wxSpinCtrl::SetSelection(long from, long to)
|
||||||
@ -201,9 +201,28 @@ void wxSpinCtrl::SetRange(int minVal, int maxVal)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||||
|
|
||||||
BlockScrollEvent();
|
GtkDisableEvents();
|
||||||
gtk_spin_button_set_range((GtkSpinButton*)m_widget, minVal, maxVal);
|
gtk_spin_button_set_range((GtkSpinButton*)m_widget, minVal, maxVal);
|
||||||
UnblockScrollEvent();
|
GtkEnableEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxSpinCtrl::GtkDisableEvents() const
|
||||||
|
{
|
||||||
|
g_signal_handlers_block_by_func( m_widget,
|
||||||
|
(gpointer)gtk_value_changed, (void*) this);
|
||||||
|
|
||||||
|
g_signal_handlers_block_by_func(m_widget,
|
||||||
|
(gpointer)gtk_changed, (void*) this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxSpinCtrl::GtkEnableEvents() const
|
||||||
|
{
|
||||||
|
g_signal_handlers_unblock_by_func(m_widget,
|
||||||
|
(gpointer)gtk_value_changed, (void*) this);
|
||||||
|
|
||||||
|
g_signal_handlers_unblock_by_func(m_widget,
|
||||||
|
(gpointer)gtk_changed, (void*) this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinCtrl::OnChar( wxKeyEvent &event )
|
void wxSpinCtrl::OnChar( wxKeyEvent &event )
|
||||||
|
Loading…
Reference in New Issue
Block a user