diff --git a/headers/os/interface/TextView.h b/headers/os/interface/TextView.h index 701e238d9e..caaeeaf746 100644 --- a/headers/os/interface/TextView.h +++ b/headers/os/interface/TextView.h @@ -336,7 +336,7 @@ private: void _RequestDrawLines(int32 startLine, int32 endLine); - void _DrawCaret(int32 offset); + void _DrawCaret(int32 offset, bool visible); void _ShowCaret(); void _HideCaret(); void _InvertCaret(); diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index 23293a56b2..9bfc67f486 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -4473,7 +4473,7 @@ BTextView::_DrawLines(int32 startLine, int32 endLine, int32 startOffset, Highlight(fSelStart, fSelEnd); } else { if (fCaretVisible) - _DrawCaret(fSelStart); + _DrawCaret(fSelStart, true); } } @@ -4512,7 +4512,7 @@ BTextView::_RequestDrawLines(int32 startLine, int32 endLine) void -BTextView::_DrawCaret(int32 offset) +BTextView::_DrawCaret(int32 offset, bool visible) { float lineHeight; BPoint caretPoint = PointAt(offset, &lineHeight); @@ -4523,7 +4523,10 @@ BTextView::_DrawCaret(int32 offset) caretRect.top = caretPoint.y; caretRect.bottom = caretPoint.y + lineHeight - 1; - InvertRect(caretRect); + if (visible) + InvertRect(caretRect); + else + Invalidate(caretRect); } @@ -4549,8 +4552,8 @@ BTextView::_HideCaret() void BTextView::_InvertCaret() { - _DrawCaret(fSelStart); fCaretVisible = !fCaretVisible; + _DrawCaret(fSelStart, fCaretVisible); fCaretTime = system_time(); } @@ -4568,7 +4571,7 @@ BTextView::_DragCaret(int32 offset) // hide the previous drag caret if (fDragOffset != -1) - _DrawCaret(fDragOffset); + _DrawCaret(fDragOffset, false); // do we have a new location? if (offset != -1) { @@ -4580,7 +4583,7 @@ BTextView::_DragCaret(int32 offset) } } - _DrawCaret(offset); + _DrawCaret(offset, true); } fDragOffset = offset;