Fix for bug #14915 - wxRichTextCtrl: Not able to move up to empty first line

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73258 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2012-12-22 21:31:13 +00:00
parent c9223c4a57
commit 76e36b9452

View File

@ -2082,6 +2082,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 +2103,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 +2139,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;