From: Julian Smart Date: Wed, 26 Mar 2008 08:48:15 +0000 (+0000) Subject: Fixed selection clearing. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c1aec196fc3e544d0188cfc975344887eeb10e0f?ds=inline Fixed selection clearing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52827 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 01cbd9387a..5df966700d 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -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(); + } } // ----------------------------------------------------------------------------