mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/text_input] ShiftUp/Down selects whole textfield on left/right
This commit is contained in:
@@ -97,7 +97,7 @@ protected:
|
||||
virtual const ContentView * nonEditableContentView() const = 0;
|
||||
bool moveCursorLeft();
|
||||
bool moveCursorRight();
|
||||
bool selectLeftRight(bool left);
|
||||
bool selectLeftRight(bool left, bool all); // While indicates if all the text on the left/right should be selected
|
||||
private:
|
||||
virtual void willSetCursorLocation(const char * * location) {}
|
||||
virtual bool privateRemoveEndOfLine();
|
||||
|
||||
@@ -109,7 +109,7 @@ bool TextArea::handleEvent(Ion::Events::Event event) {
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::ShiftLeft || event == Ion::Events::ShiftRight) {
|
||||
selectLeftRight(event == Ion::Events::ShiftLeft);
|
||||
selectLeftRight(event == Ion::Events::ShiftLeft, false);
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::ShiftUp ||event == Ion::Events::ShiftDown) {
|
||||
|
||||
@@ -481,8 +481,8 @@ bool TextField::privateHandleSelectEvent(Ion::Events::Event event) {
|
||||
if (!isEditing()) {
|
||||
return false;
|
||||
}
|
||||
if (event == Ion::Events::ShiftLeft || event == Ion::Events::ShiftRight) {
|
||||
selectLeftRight(event == Ion::Events::ShiftLeft);
|
||||
if (event == Ion::Events::ShiftLeft || event == Ion::Events::ShiftRight || event == Ion::Events::ShiftUp || event == Ion::Events::ShiftDown) {
|
||||
selectLeftRight(event == Ion::Events::ShiftLeft || event == Ion::Events::ShiftUp, event == Ion::Events::ShiftUp || event == Ion::Events::ShiftDown);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -206,13 +206,23 @@ bool TextInput::moveCursorRight() {
|
||||
return setCursorLocation(decoder.nextGlyphPosition());
|
||||
}
|
||||
|
||||
bool TextInput::selectLeftRight(bool left) {
|
||||
bool TextInput::selectLeftRight(bool left, bool all) {
|
||||
const char * cursorLoc = cursorLocation();
|
||||
bool moved = left ? moveCursorLeft() : moveCursorRight();
|
||||
if (!moved) {
|
||||
return false;
|
||||
const char * nextCursorLoc = nullptr;
|
||||
if (!all) {
|
||||
bool moved = left ? moveCursorLeft() : moveCursorRight();
|
||||
if (!moved) {
|
||||
return false;
|
||||
}
|
||||
nextCursorLoc = cursorLocation();
|
||||
} else {
|
||||
const char * t = text();
|
||||
nextCursorLoc = left ? t : t + strlen(t);
|
||||
if (cursorLoc == nextCursorLoc) {
|
||||
return false;
|
||||
}
|
||||
setCursorLocation(nextCursorLoc);
|
||||
}
|
||||
const char * nextCursorLoc = cursorLocation();
|
||||
contentView()->addSelection(left ? nextCursorLoc : cursorLoc, left ? cursorLoc : nextCursorLoc);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user