X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e2ccb25092ea0b6e94968823cbfc7d9b97326de7..80e5b0b1434abc35ec77279ee42b5237bdee854d:/src/gtk/textctrl.cpp diff --git a/src/gtk/textctrl.cpp b/src/gtk/textctrl.cpp index 325dcbd5c6..8d5648bd77 100644 --- a/src/gtk/textctrl.cpp +++ b/src/gtk/textctrl.cpp @@ -494,6 +494,27 @@ au_delete_range_callback(GtkTextBuffer * WXUNUSED(buffer), } } +//----------------------------------------------------------------------------- +// "populate_popup" from text control and "unmap" from its poup menu +//----------------------------------------------------------------------------- + +extern "C" { +static void +gtk_textctrl_popup_unmap( GtkMenu *WXUNUSED(menu), wxTextCtrl* win ) +{ + win->GTKEnableFocusOutEvent(); +} +} + +extern "C" { +static void +gtk_textctrl_populate_popup( GtkEntry *WXUNUSED(entry), GtkMenu *menu, wxTextCtrl *win ) +{ + win->GTKDisableFocusOutEvent(); + + g_signal_connect (menu, "unmap", G_CALLBACK (gtk_textctrl_popup_unmap), win ); +} +} //----------------------------------------------------------------------------- // "changed" @@ -501,7 +522,7 @@ au_delete_range_callback(GtkTextBuffer * WXUNUSED(buffer), extern "C" { static void -gtk_text_changed_callback( GtkWidget * WXUNUSED(widget), wxTextCtrl *win ) +gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) { if ( win->IgnoreTextUpdate() ) return; @@ -687,6 +708,7 @@ bool wxTextCtrl::Create( wxWindow *parent, g_object_set (m_text, "has-frame", FALSE, NULL); } + g_object_ref(m_widget); m_parent->DoAddChild( this ); @@ -711,6 +733,11 @@ bool wxTextCtrl::Create( wxWindow *parent, G_CALLBACK (gtk_text_changed_callback), this); } + // Catch to disable focus out handling + g_signal_connect (m_text, "populate_popup", + G_CALLBACK (gtk_textctrl_populate_popup), + this); + if (!value.empty()) { SetValue( value ); @@ -1006,9 +1033,6 @@ void wxTextCtrl::DoSetValue( const wxString &value, int flags ) { EnableTextChangedEvents(true); } - - // This was added after discussion on the list - SetInsertionPoint(0); } void wxTextCtrl::WriteText( const wxString &text ) @@ -1320,7 +1344,7 @@ void wxTextCtrl::SetSelection( long from, long to ) gtk_text_buffer_get_iter_at_offset( m_buffer, &fromi, from ); gtk_text_buffer_get_iter_at_offset( m_buffer, &toi, to ); - gtk_text_buffer_place_cursor( m_buffer, &toi ); + gtk_text_buffer_place_cursor( m_buffer, &fromi ); gtk_text_buffer_move_mark_by_name( m_buffer, "selection_bound", &fromi ); } else // single line