mirror of https://github.com/buggins/dlangui.git
Call correctCaretPos() after keyboard navigation
If the up/down arrow keys were used for keyboard navigation in a multiline editbox, the position of the caret would become invalid because it was not updated to fit in the new line. This caused incorrect behaviour when entering text after such navigation (ie replacing text when it should have appended).
This commit is contained in:
parent
6328b11286
commit
d4fb6b8b6b
|
@ -2390,6 +2390,7 @@ class EditBox : EditWidgetBase {
|
||||||
case SelectUp:
|
case SelectUp:
|
||||||
if (_caretPos.line > 0) {
|
if (_caretPos.line > 0) {
|
||||||
_caretPos.line--;
|
_caretPos.line--;
|
||||||
|
correctCaretPos();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
ensureCaretVisible();
|
ensureCaretVisible();
|
||||||
}
|
}
|
||||||
|
@ -2398,6 +2399,7 @@ class EditBox : EditWidgetBase {
|
||||||
case SelectDown:
|
case SelectDown:
|
||||||
if (_caretPos.line < _content.length - 1) {
|
if (_caretPos.line < _content.length - 1) {
|
||||||
_caretPos.line++;
|
_caretPos.line++;
|
||||||
|
correctCaretPos();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
ensureCaretVisible();
|
ensureCaretVisible();
|
||||||
}
|
}
|
||||||
|
@ -2407,6 +2409,7 @@ class EditBox : EditWidgetBase {
|
||||||
{
|
{
|
||||||
ensureCaretVisible();
|
ensureCaretVisible();
|
||||||
_caretPos.line = _firstVisibleLine;
|
_caretPos.line = _firstVisibleLine;
|
||||||
|
correctCaretPos();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2419,6 +2422,7 @@ class EditBox : EditWidgetBase {
|
||||||
if (newpos >= _content.length)
|
if (newpos >= _content.length)
|
||||||
newpos = _content.length - 1;
|
newpos = _content.length - 1;
|
||||||
_caretPos.line = newpos;
|
_caretPos.line = newpos;
|
||||||
|
correctCaretPos();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2436,6 +2440,7 @@ class EditBox : EditWidgetBase {
|
||||||
_firstVisibleLine = newpos;
|
_firstVisibleLine = newpos;
|
||||||
_caretPos.line -= delta;
|
_caretPos.line -= delta;
|
||||||
}
|
}
|
||||||
|
correctCaretPos();
|
||||||
measureVisibleText();
|
measureVisibleText();
|
||||||
updateScrollBars();
|
updateScrollBars();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
|
@ -2454,6 +2459,7 @@ class EditBox : EditWidgetBase {
|
||||||
_firstVisibleLine = newpos;
|
_firstVisibleLine = newpos;
|
||||||
_caretPos.line += delta;
|
_caretPos.line += delta;
|
||||||
}
|
}
|
||||||
|
correctCaretPos();
|
||||||
measureVisibleText();
|
measureVisibleText();
|
||||||
updateScrollBars();
|
updateScrollBars();
|
||||||
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
updateSelectionAfterCursorMovement(oldCaretPos, (a.id & 1) != 0);
|
||||||
|
|
Loading…
Reference in New Issue