X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/732281950a766e94828787ff571f73fecb83949e..68a335b43ba9358c29801a638313c826a2c96c90:/src/richtext/richtextctrl.cpp diff --git a/src/richtext/richtextctrl.cpp b/src/richtext/richtextctrl.cpp index 9b40064ee8..06dbf17af1 100644 --- a/src/richtext/richtextctrl.cpp +++ b/src/richtext/richtextctrl.cpp @@ -751,6 +751,14 @@ void wxRichTextCtrl::OnLeftUp(wxMouseEvent& event) /// Mouse-movements void wxRichTextCtrl::OnMoveMouse(wxMouseEvent& event) { + if (!event.Dragging() && m_dragging) + { + // We may have accidentally lost a mouse-up event, especially on Linux + m_dragging = false; + if (GetCapture() == this) + ReleaseMouse(); + } + #if wxUSE_DRAG_AND_DROP size_t distance = 0; if (m_preDrag || m_dragging) @@ -2082,6 +2090,7 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags) wxRichTextParagraphLayoutBox* container = GetFocusObject(); int hitTestFlags = wxRICHTEXT_HITTEST_NO_NESTED_OBJECTS|wxRICHTEXT_HITTEST_NO_FLOATING_OBJECTS|wxRICHTEXT_HITTEST_HONOUR_ATOMIC; + bool lineIsEmpty = false; if (notInThisObject) { // If we know we're navigating out of the current object, @@ -2102,7 +2111,11 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags) { wxRichTextLine* lineObj = GetFocusObject()->GetLineForVisibleLineNumber(newLine); if (lineObj) + { pt.y = lineObj->GetAbsolutePosition().y + 2; + if (lineObj->GetRange().GetStart() == lineObj->GetRange().GetEnd()) + lineIsEmpty = true; + } else return false; } @@ -2134,6 +2147,15 @@ bool wxRichTextCtrl::MoveDown(int noLines, int flags) } bool caretLineStart = true; + + // If the line is empty, there is only one possible position for the caret, + // so force the 'before' state so FindCaretPositionForCharacterPosition doesn't + // just return the same position. + if (lineIsEmpty) + { + hitTest &= ~wxRICHTEXT_HITTEST_AFTER; + hitTest |= wxRICHTEXT_HITTEST_BEFORE; + } long caretPosition = FindCaretPositionForCharacterPosition(newPos, hitTest, container, caretLineStart); long newSelEnd = caretPosition; bool extendSel; @@ -3244,7 +3266,8 @@ void wxRichTextCtrl::Replace(long from, long to, SetDefaultStyle(attr); - DoWriteText(value, SetValue_SelectionOnly); + if (!value.IsEmpty()) + DoWriteText(value, SetValue_SelectionOnly); EndBatchUndo(); }