mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 14:31:50 +00:00
fix selection reset on end reached with shift pressed
This commit is contained in:
parent
47f2bf75d7
commit
1d4abd7758
2 changed files with 13 additions and 32 deletions
|
|
@ -755,15 +755,16 @@ void TextBox::resetMaxLocalCaret() {
|
||||||
caret - label->getTextLineOffset(label->getLineByTextIndex(caret));
|
caret - label->getTextLineOffset(label->getLineByTextIndex(caret));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBox::stepLeft(bool shiftPressed, bool breakSelection) {
|
void TextBox::stepCaret(bool shiftPressed, bool breakSelection, bool right) {
|
||||||
uint previousCaret = this->caret;
|
uint previousCaret = this->caret;
|
||||||
size_t caret = breakSelection ? selectionStart : this->caret;
|
size_t caret =
|
||||||
if (caret > 0) {
|
breakSelection ? (right ? selectionEnd : selectionStart) : this->caret;
|
||||||
if (caret > input.length()) {
|
if (right ? (caret < input.length()) : (caret > 0)) {
|
||||||
setCaret(input.length() - 1);
|
setCaret(
|
||||||
} else {
|
right ? (caret + 1)
|
||||||
setCaret(caret - 1);
|
: ((caret > input.length()) ? (input.length() - 1)
|
||||||
}
|
: (caret - 1))
|
||||||
|
);
|
||||||
if (shiftPressed) {
|
if (shiftPressed) {
|
||||||
if (selectionStart == selectionEnd) {
|
if (selectionStart == selectionEnd) {
|
||||||
selectionOrigin = previousCaret;
|
selectionOrigin = previousCaret;
|
||||||
|
|
@ -774,28 +775,9 @@ void TextBox::stepLeft(bool shiftPressed, bool breakSelection) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setCaret(caret);
|
setCaret(caret);
|
||||||
resetSelection();
|
if (!shiftPressed) {
|
||||||
}
|
|
||||||
resetMaxLocalCaret();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextBox::stepRight(bool shiftPressed, bool breakSelection) {
|
|
||||||
uint previousCaret = this->caret;
|
|
||||||
size_t caret = breakSelection ? selectionEnd : this->caret;
|
|
||||||
if (caret < input.length()) {
|
|
||||||
setCaret(caret + 1);
|
|
||||||
caretLastMove = gui.getWindow().time();
|
|
||||||
if (shiftPressed) {
|
|
||||||
if (selectionStart == selectionEnd) {
|
|
||||||
selectionOrigin = previousCaret;
|
|
||||||
}
|
|
||||||
extendSelection(this->caret);
|
|
||||||
} else {
|
|
||||||
resetSelection();
|
resetSelection();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
setCaret(caret);
|
|
||||||
resetSelection();
|
|
||||||
}
|
}
|
||||||
resetMaxLocalCaret();
|
resetMaxLocalCaret();
|
||||||
}
|
}
|
||||||
|
|
@ -983,9 +965,9 @@ void TextBox::performEditingKeyboardEvents(Keycode key) {
|
||||||
} else if (key == Keycode::TAB) {
|
} else if (key == Keycode::TAB) {
|
||||||
onTab(shiftPressed);
|
onTab(shiftPressed);
|
||||||
} else if (key == Keycode::LEFT) {
|
} else if (key == Keycode::LEFT) {
|
||||||
stepLeft(shiftPressed, breakSelection);
|
stepCaret(shiftPressed, breakSelection, false);
|
||||||
} else if (key == Keycode::RIGHT) {
|
} else if (key == Keycode::RIGHT) {
|
||||||
stepRight(shiftPressed, breakSelection);
|
stepCaret(shiftPressed, breakSelection, true);
|
||||||
} else if (key == Keycode::UP && onUpPressed) {
|
} else if (key == Keycode::UP && onUpPressed) {
|
||||||
onUpPressed();
|
onUpPressed();
|
||||||
} else if (key == Keycode::DOWN && onDownPressed) {
|
} else if (key == Keycode::DOWN && onDownPressed) {
|
||||||
|
|
|
||||||
|
|
@ -66,8 +66,7 @@ namespace gui {
|
||||||
std::string markup;
|
std::string markup;
|
||||||
std::string syntax;
|
std::string syntax;
|
||||||
|
|
||||||
void stepLeft(bool shiftPressed, bool breakSelection);
|
void stepCaret(bool shiftPressed, bool breakSelection, bool right);
|
||||||
void stepRight(bool shiftPressed, bool breakSelection);
|
|
||||||
void stepDefaultDown(bool shiftPressed, bool breakSelection);
|
void stepDefaultDown(bool shiftPressed, bool breakSelection);
|
||||||
void stepDefaultUp(bool shiftPressed, bool breakSelection);
|
void stepDefaultUp(bool shiftPressed, bool breakSelection);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue