X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0d91b2342a1f83b3b9db145c7210efd5d9547cc8..923608c3ac95e2c705fb0f49ab48fbe62fc871bd:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 1c599667a9..703ceccd9c 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -31,12 +31,6 @@ #include "wx/gtk/private.h" #include -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern wxWindowGTK *g_delayedFocus; - // ---------------------------------------------------------------------------- // helpers // ---------------------------------------------------------------------------- @@ -846,7 +840,9 @@ void wxTextCtrl::SetValue( const wxString &value ) const wxCharBuffer buffer(wxGTK_CONV_ENC(value, GetTextEncoding())); if ( !buffer ) { - // what else can we do? at least don't crash... + // see comment in WriteText() as to why we must warn the user about + // this + wxLogWarning(_("Failed to set text in the text control.")); return; } @@ -857,10 +853,11 @@ void wxTextCtrl::SetValue( const wxString &value ) } else // single line { - // gtk_entry_set_text() emits two "changed" signals because internally - // it calls gtk_editable_delete_text() and gtk_editable_insert_text() - // but we want to have only one event - IgnoreNextTextUpdate(); + // gtk_entry_set_text() emits two "changed" signals if the control is + // not empty because internally it calls gtk_editable_delete_text() and + // gtk_editable_insert_text() but we want to have only one event + if ( !GetValue().empty() ) + IgnoreNextTextUpdate(); gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV(value) ); } @@ -1545,15 +1542,16 @@ GtkWidget* wxTextCtrl::GetConnectWidget() return GTK_WIDGET(m_text); } -bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) +GdkWindow *wxTextCtrl::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const { if ( IsMultiLine() ) { - return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork + return gtk_text_view_get_window(GTK_TEXT_VIEW(m_text), + GTK_TEXT_WINDOW_TEXT ); } else { - return (window == GTK_ENTRY(m_text)->text_area); + return GTK_ENTRY(m_text)->text_area; } } @@ -1715,24 +1713,6 @@ void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event) event.Enable( CanRedo() ); } -void wxTextCtrl::OnInternalIdle() -{ - // Check if we have to show window now - if (GtkShowFromOnIdle()) return; - - if (g_delayedFocus == this) - { - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_grab_focus( m_widget ); - g_delayedFocus = NULL; - } - } - - if (wxUpdateUIEvent::CanUpdate(this)) - UpdateWindowUI(wxUPDATE_UI_FROMIDLE); -} - wxSize wxTextCtrl::DoGetBestSize() const { // FIXME should be different for multi-line controls... @@ -1837,6 +1817,18 @@ void wxTextCtrl::OnUrlMouseEvent(wxMouseEvent& event) GetEventHandler()->ProcessEvent(url_event); } +bool wxTextCtrl::GTKProcessEvent(wxEvent& event) const +{ + bool rc = wxTextCtrlBase::GTKProcessEvent(event); + + // GtkTextView starts a drag operation when left mouse button is pressed + // and ends it when it is released and if it doesn't get the release event + // the next click on a control results in an assertion failure inside + // gtk_text_view_start_selection_drag() which simply *kills* the program + // without anything we can do about it, so always let GTK+ have this event + return rc && (IsSingleLine() || event.GetEventType() != wxEVT_LEFT_UP); +} + // static wxVisualAttributes wxTextCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))