Rewrote code that prevents (double) TEXT_UPDATE events
in wxTextCtrl::SetValue(). This should fix [ 1735374 ] EVT_TEXT doesn't get called when changing wxTextCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -756,9 +756,21 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
|||||||
gtk_widget_show(m_text);
|
gtk_widget_show(m_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (multi_line)
|
||||||
|
{
|
||||||
|
g_signal_connect (m_buffer, "changed",
|
||||||
|
G_CALLBACK (gtk_text_changed_callback), this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_signal_connect (m_text, "changed",
|
||||||
|
G_CALLBACK (gtk_text_changed_callback), this);
|
||||||
|
}
|
||||||
|
|
||||||
if (!value.empty())
|
if (!value.empty())
|
||||||
{
|
{
|
||||||
SetValue( value );
|
DoSetValue( value, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style & wxTE_PASSWORD)
|
if (style & wxTE_PASSWORD)
|
||||||
@@ -771,13 +783,9 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
|||||||
if ( style & (wxTE_RIGHT | wxTE_CENTRE) )
|
if ( style & (wxTE_RIGHT | wxTE_CENTRE) )
|
||||||
GTKSetJustification();
|
GTKSetJustification();
|
||||||
|
|
||||||
// We want to be notified about text changes.
|
|
||||||
if (multi_line)
|
if (multi_line)
|
||||||
{
|
{
|
||||||
g_signal_connect (m_buffer, "changed",
|
// Handle URLs on multi-line controls with wxTE_AUTO_URL style
|
||||||
G_CALLBACK (gtk_text_changed_callback), this);
|
|
||||||
|
|
||||||
// .. and handle URLs on multi-line controls with wxTE_AUTO_URL style
|
|
||||||
if (style & wxTE_AUTO_URL)
|
if (style & wxTE_AUTO_URL)
|
||||||
{
|
{
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
@@ -813,11 +821,6 @@ bool wxTextCtrl::Create( wxWindow *parent,
|
|||||||
au_check_range(&start, &end);
|
au_check_range(&start, &end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
g_signal_connect (m_text, "changed",
|
|
||||||
G_CALLBACK (gtk_text_changed_callback), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_signal_connect (m_text, "copy-clipboard",
|
g_signal_connect (m_text, "copy-clipboard",
|
||||||
G_CALLBACK (gtk_copy_clipboard_callback), this);
|
G_CALLBACK (gtk_copy_clipboard_callback), this);
|
||||||
@@ -1002,12 +1005,7 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
|
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
|
||||||
|
|
||||||
// the control won't be modified any more as we programmatically replace
|
|
||||||
// all the existing text, so reset the flag and don't set it again (and do
|
|
||||||
// it now, before the text event handler is ran so that IsModified() called
|
|
||||||
// from there returns the expected value)
|
|
||||||
m_modified = false;
|
m_modified = false;
|
||||||
DontMarkDirtyOnNextChange();
|
|
||||||
|
|
||||||
const wxCharBuffer buffer(wxGTK_CONV_ENC(value, GetTextEncoding()));
|
const wxCharBuffer buffer(wxGTK_CONV_ENC(value, GetTextEncoding()));
|
||||||
if ( !buffer )
|
if ( !buffer )
|
||||||
@@ -1018,34 +1016,33 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the control is not empty, two "changed" signals are emitted,
|
|
||||||
// otherwise only one and we need to ignore either both or one of them
|
|
||||||
int ignore = flags & SetValue_SendEvent ? 0 : 1;
|
|
||||||
if ( !IsEmpty() )
|
|
||||||
ignore++;
|
|
||||||
|
|
||||||
if ( ignore )
|
|
||||||
IgnoreNextTextUpdate(ignore);
|
|
||||||
|
|
||||||
if ( IsMultiLine() )
|
if ( IsMultiLine() )
|
||||||
{
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (m_buffer,
|
||||||
|
(gpointer) gtk_text_changed_callback, this);
|
||||||
|
|
||||||
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
|
gtk_text_buffer_set_text( m_buffer, buffer, strlen(buffer) );
|
||||||
|
|
||||||
|
|
||||||
|
g_signal_connect (m_buffer, "changed",
|
||||||
|
G_CALLBACK (gtk_text_changed_callback), this);
|
||||||
}
|
}
|
||||||
else // single line
|
else
|
||||||
{
|
{
|
||||||
|
g_signal_handlers_disconnect_by_func (m_text,
|
||||||
|
(gpointer) gtk_text_changed_callback, this);
|
||||||
|
|
||||||
gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
|
gtk_entry_set_text( GTK_ENTRY(m_text), buffer );
|
||||||
|
|
||||||
|
g_signal_connect (m_text, "changed",
|
||||||
|
G_CALLBACK (gtk_text_changed_callback), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if, for whatever reason, the callback wasn't called the expected number
|
// This was added after discussion on the list
|
||||||
// of times, still reset the flags to the default values
|
|
||||||
m_dontMarkDirty = false;
|
|
||||||
m_countUpdatesToIgnore = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// GRG, Jun/2000: Changed this after a lot of discussion in
|
|
||||||
// the lists. wxWidgets 2.2 will have a set of flags to
|
|
||||||
// customize this behaviour.
|
|
||||||
SetInsertionPoint(0);
|
SetInsertionPoint(0);
|
||||||
|
|
||||||
|
if (flags & SetValue_SendEvent)
|
||||||
|
SendTextUpdatedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTextCtrl::WriteText( const wxString &text )
|
void wxTextCtrl::WriteText( const wxString &text )
|
||||||
|
Reference in New Issue
Block a user