mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Merge pull request #370 from M4xi1m3/e14-bf2
[escher] Fixed alpha+arrow / alpha-lock + arrow
This commit is contained in:
@@ -100,6 +100,8 @@ protected:
|
||||
virtual const ContentView * nonEditableContentView() const = 0;
|
||||
bool moveCursorLeft();
|
||||
bool moveCursorRight();
|
||||
bool moveCursorBegin();
|
||||
bool moveCursorEnd();
|
||||
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) {}
|
||||
|
||||
@@ -133,28 +133,30 @@ HighlightCell * SelectableTableView::selectedCell() {
|
||||
}
|
||||
|
||||
bool SelectableTableView::handleEvent(Ion::Events::Event event) {
|
||||
bool noAlphaLock = Ion::Events::shiftAlphaStatus() != Ion::Events::ShiftAlphaStatus::AlphaLock && Ion::Events::shiftAlphaStatus() != Ion::Events::ShiftAlphaStatus::ShiftAlphaLock;
|
||||
|
||||
if (event == Ion::Events::Down) {
|
||||
return selectCellAtLocation(selectedColumn(), selectedRow()+1);
|
||||
}
|
||||
if ((event == Ion::Events::ShiftDown || event == Ion::Events::AlphaDown) && selectedRow() < dataSource()->numberOfRows()-1) {
|
||||
if ((noAlphaLock && event == Ion::Events::AlphaDown) && selectedRow() < dataSource()->numberOfRows()-1) {
|
||||
return selectCellAtLocation(selectedColumn(), dataSource()->numberOfRows()-1);
|
||||
}
|
||||
if (event == Ion::Events::Up) {
|
||||
return selectCellAtLocation(selectedColumn(), selectedRow()-1);
|
||||
}
|
||||
if ((event == Ion::Events::ShiftUp || event == Ion::Events::AlphaUp) && selectedRow() > 0) {
|
||||
if ((noAlphaLock && event == Ion::Events::AlphaUp) && selectedRow() > 0) {
|
||||
return selectCellAtLocation(selectedColumn(), 0);
|
||||
}
|
||||
if (event == Ion::Events::Left) {
|
||||
return selectCellAtLocation(selectedColumn()-1, selectedRow());
|
||||
}
|
||||
if ((event == Ion::Events::ShiftLeft || event == Ion::Events::AlphaLeft) && selectedColumn() > 0) {
|
||||
if ((noAlphaLock && event == Ion::Events::AlphaLeft) && selectedColumn() > 0) {
|
||||
return selectCellAtLocation(0, selectedRow());
|
||||
}
|
||||
if (event == Ion::Events::Right) {
|
||||
return selectCellAtLocation(selectedColumn()+1, selectedRow());
|
||||
}
|
||||
if ((event == Ion::Events::ShiftRight || event == Ion::Events::AlphaRight) && selectedColumn() < dataSource()->numberOfColumns()-1) {
|
||||
if ((noAlphaLock && event == Ion::Events::AlphaRight) && selectedColumn() < dataSource()->numberOfColumns()-1) {
|
||||
return selectCellAtLocation(dataSource()->numberOfColumns()-1, selectedRow());
|
||||
}
|
||||
if (event == Ion::Events::Copy || event == Ion::Events::Cut) {
|
||||
|
||||
@@ -100,6 +100,8 @@ bool TextArea::handleEventWithText(const char * text, bool indentation, bool for
|
||||
}
|
||||
|
||||
bool TextArea::handleEvent(Ion::Events::Event event) {
|
||||
bool noAlphaLock = Ion::Events::shiftAlphaStatus() != Ion::Events::ShiftAlphaStatus::AlphaLock && Ion::Events::shiftAlphaStatus() != Ion::Events::ShiftAlphaStatus::ShiftAlphaLock;
|
||||
|
||||
if (m_delegate != nullptr && m_delegate->textAreaDidReceiveEvent(this, event)) {
|
||||
return true;
|
||||
}
|
||||
@@ -113,25 +115,21 @@ bool TextArea::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::ShiftUp || event == Ion::Events::ShiftDown) {
|
||||
selectUpDown(event == Ion::Events::ShiftUp);
|
||||
return true;
|
||||
} else if (event == Ion::Events::AlphaLeft) {
|
||||
} else if (noAlphaLock && event == Ion::Events::AlphaLeft) {
|
||||
contentView()->moveCursorGeo(-INT_MAX/2, 0);
|
||||
TextInput::scrollToCursor();
|
||||
} else if (event == Ion::Events::AlphaRight) {
|
||||
return true;
|
||||
} else if (noAlphaLock && event == Ion::Events::AlphaRight) {
|
||||
contentView()->moveCursorGeo(INT_MAX/2, 0);
|
||||
TextInput::scrollToCursor();
|
||||
} else if (event == Ion::Events::AlphaUp) {
|
||||
contentView()->moveCursorGeo(0, -INT_MAX/2);
|
||||
TextInput::scrollToCursor();
|
||||
} else if (event == Ion::Events::AlphaDown) {
|
||||
contentView()->moveCursorGeo(0, INT_MAX/2);
|
||||
TextInput::scrollToCursor();
|
||||
} else if (event == Ion::Events::Left) {
|
||||
return true;
|
||||
} else if (event == Ion::Events::Left || event == Ion::Events::AlphaLeft) {
|
||||
if (contentView()->resetSelection()) {
|
||||
return true;
|
||||
}
|
||||
return TextInput::moveCursorLeft();
|
||||
}
|
||||
if (event == Ion::Events::Right) {
|
||||
if (event == Ion::Events::Right || event == Ion::Events::AlphaRight) {
|
||||
if (contentView()->resetSelection()) {
|
||||
return true;
|
||||
}
|
||||
@@ -169,10 +167,18 @@ bool TextArea::handleEvent(Ion::Events::Event event) {
|
||||
deleteSelection();
|
||||
return true;
|
||||
}
|
||||
} else if (event == Ion::Events::Up) {
|
||||
} else if (noAlphaLock && event == Ion::Events::AlphaUp) {
|
||||
contentView()->moveCursorGeo(0, -INT_MAX/2);
|
||||
TextInput::scrollToCursor();
|
||||
return true;
|
||||
} else if (noAlphaLock && event == Ion::Events::AlphaDown) {
|
||||
contentView()->moveCursorGeo(0, INT_MAX/2);
|
||||
TextInput::scrollToCursor();
|
||||
return true;
|
||||
} else if (event == Ion::Events::Up || event == Ion::Events::AlphaUp) {
|
||||
contentView()->resetSelection();
|
||||
contentView()->moveCursorGeo(0, -1);
|
||||
} else if (event == Ion::Events::Down) {
|
||||
} else if (event == Ion::Events::Down || event == Ion::Events::AlphaDown) {
|
||||
contentView()->resetSelection();
|
||||
contentView()->moveCursorGeo(0, 1);
|
||||
} else if (event == Ion::Events::Backspace) {
|
||||
|
||||
@@ -317,10 +317,14 @@ bool TextField::privateHandleEvent(Ion::Events::Event event) {
|
||||
/* If a move event was not caught before, we handle it here to avoid bubbling
|
||||
* the event up. */
|
||||
if (isEditing()
|
||||
&& (event == Ion::Events::Up
|
||||
&& (event == Ion::Events::Up
|
||||
|| event == Ion::Events::AlphaUp
|
||||
|| event == Ion::Events::Down
|
||||
|| event == Ion::Events::AlphaDown
|
||||
|| event == Ion::Events::Left
|
||||
|| event == Ion::Events::Right))
|
||||
|| event == Ion::Events::AlphaLeft
|
||||
|| event == Ion::Events::Right
|
||||
|| event == Ion::Events::AlphaRight))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -459,17 +463,25 @@ bool TextField::privateHandleMoveEvent(Ion::Events::Event event) {
|
||||
return false;
|
||||
}
|
||||
const char * draftBuffer = m_contentView.editedText();
|
||||
if (event == Ion::Events::Left || event == Ion::Events::Right) {
|
||||
if (event == Ion::Events::Left || event == Ion::Events::AlphaLeft || event == Ion::Events::Right || event == Ion::Events::AlphaRight) {
|
||||
bool noAlphaLock = Ion::Events::shiftAlphaStatus() != Ion::Events::ShiftAlphaStatus::AlphaLock && Ion::Events::shiftAlphaStatus() != Ion::Events::ShiftAlphaStatus::ShiftAlphaLock;
|
||||
|
||||
if (!m_contentView.selectionIsEmpty()) {
|
||||
resetSelection();
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Left && cursorLocation() > draftBuffer) {
|
||||
if ((event == Ion::Events::Left || (event == Ion::Events::AlphaLeft && !noAlphaLock)) && cursorLocation() > draftBuffer) {
|
||||
return TextInput::moveCursorLeft();
|
||||
}
|
||||
if (event == Ion::Events::Right && cursorLocation() < draftBuffer + draftTextLength()) {
|
||||
if (event == Ion::Events::AlphaLeft && noAlphaLock && cursorLocation() > draftBuffer) {
|
||||
return TextInput::moveCursorBegin();
|
||||
}
|
||||
if ((event == Ion::Events::Right || (event == Ion::Events::AlphaRight && !noAlphaLock)) && cursorLocation() < draftBuffer + draftTextLength()) {
|
||||
return TextInput::moveCursorRight();
|
||||
}
|
||||
if (event == Ion::Events::AlphaRight && noAlphaLock && cursorLocation() < draftBuffer + draftTextLength()) {
|
||||
return TextInput::moveCursorEnd();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,29 @@ bool TextInput::removeEndOfLine() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TextInput::moveCursorBegin() {
|
||||
if (cursorLocation() <= text()) {
|
||||
assert(cursorLocation() == text());
|
||||
return false;
|
||||
}
|
||||
|
||||
return setCursorLocation(text());
|
||||
}
|
||||
|
||||
bool TextInput::moveCursorEnd() {
|
||||
if (UTF8Helper::CodePointIs(cursorLocation(), UCodePointNull)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UTF8Decoder decoder(text(), cursorLocation());
|
||||
|
||||
while(decoder.nextCodePoint() != UCodePointNull) {
|
||||
decoder.setPosition(decoder.nextGlyphPosition());
|
||||
}
|
||||
|
||||
return setCursorLocation(decoder.stringPosition());
|
||||
}
|
||||
|
||||
bool TextInput::moveCursorLeft() {
|
||||
if (cursorLocation() <= text()) {
|
||||
assert(cursorLocation() == text());
|
||||
|
||||
Reference in New Issue
Block a user