]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix wxTextEntry::SelectAll() in presence of hints in wxGTK.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 15 Sep 2010 22:10:07 +0000 (22:10 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 15 Sep 2010 22:10:07 +0000 (22:10 +0000)
Translation of wx (-1, -1) selection to (0, GetValue().length()) in
wxTextCtrl::SetSelection() was unnecessary as it ended up calling the base
class wxTextEntry::SetSelection() version which didn't need it. Moreover, this
translation was actually harmful when the text control happened to show a hint
string as its official value was empty in this case and so SetSelection(0, 0)
was called which didn't do anything and broke clearing/changing the controls
text when it was showing a hint.

Simply don't translate the indices when using a single line control to fix
this.

See #12475.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65550 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/textctrl.cpp

index f5a78bdf8d1ac02f480c5259ba70d55574eab6ca..c8f61f1ed92cfb6b3c34627ea46781e3cbc52f88 100644 (file)
@@ -1334,14 +1334,14 @@ void wxTextCtrl::SetSelection( long from, long to )
 {
     wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
 
-    if (from == -1 && to == -1)
-    {
-        from = 0;
-        to = GetValue().length();
-    }
-
     if ( IsMultiLine() )
     {
+        if (from == -1 && to == -1)
+        {
+            from = 0;
+            to = GetValue().length();
+        }
+
         GtkTextIter fromi, toi;
         gtk_text_buffer_get_iter_at_offset( m_buffer, &fromi, from );
         gtk_text_buffer_get_iter_at_offset( m_buffer, &toi, to );