]> git.saurik.com Git - wxWidgets.git/commitdiff
Add code to remove the selection (if any) in wxTextCtrl::WriteText for multi-line...
authorRobin Dunn <robin@alldunn.com>
Thu, 20 Apr 2006 04:23:36 +0000 (04:23 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 20 Apr 2006 04:23:36 +0000 (04:23 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/textctrl.cpp

index 53c0f6939623b77458ed99c23da14f15e4642e0e..8e7593fe01d87d5fe1842207a78725e9dbe399f9 100644 (file)
@@ -812,7 +812,14 @@ void wxTextCtrl::WriteText( const wxString &text )
 
     if ( m_windowStyle & wxTE_MULTILINE )
     {
 
     if ( m_windowStyle & wxTE_MULTILINE )
     {
-        // TODO: Call whatever is needed to delete the selection.
+        // First remove the selection if there is one
+        // TODO:  Is there an easier GTK specific way to do this?
+        long from, to;
+        GetSelection(&from, &to);
+        if (from != to)
+            Remove(from, to);
+
+        // Insert the text
         wxGtkTextInsert( m_text, m_buffer, m_defaultStyle, buffer );
 
         GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );
         wxGtkTextInsert( m_text, m_buffer, m_defaultStyle, buffer );
 
         GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment( GTK_SCROLLED_WINDOW(m_widget) );