]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed selection clearing.
authorJulian Smart <julian@anthemion.co.uk>
Wed, 26 Mar 2008 08:48:15 +0000 (08:48 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Wed, 26 Mar 2008 08:48:15 +0000 (08:48 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52827 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/richtext/richtextctrl.cpp

index 01cbd9387a36a2b5c190c7b5bdf2ebe44e83ad4a..5df966700d1b5e72428ca51cdae244a253d2e0dd 100644 (file)
@@ -1954,7 +1954,10 @@ void wxRichTextCtrl::SelectAll()
 void wxRichTextCtrl::SelectNone()
 {
     if (!(GetSelectionRange() == wxRichTextRange(-2, -2)))
-        SetSelection(-2, -2);
+    {
+        Refresh(false);
+        m_selectionRange = wxRichTextRange(-2, -2);
+    }
     m_selectionAnchor = -2;
 }
 
@@ -2332,13 +2335,20 @@ void wxRichTextCtrl::SetSelection(long from, long to)
 
 void wxRichTextCtrl::DoSetSelection(long from, long to, bool WXUNUSED(scrollCaret))
 {
-    m_selectionAnchor = from;
-    m_selectionRange.SetRange(from, to-1);
-    if (from > -2)
-        m_caretPosition = from-1;
+    if (from == to)
+    {
+        SelectNone();
+    }
+    else
+    {
+        m_selectionAnchor = from;
+        m_selectionRange.SetRange(from, to-1);
+        if (from > -2)
+            m_caretPosition = from-1;
 
-    Refresh(false);
-    PositionCaret();
+        Refresh(false);
+        PositionCaret();
+    }
 }
 
 // ----------------------------------------------------------------------------