mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[escher] In textfield: change the behaviour of clear event
Change-Id: I6292faf383e40e7a9b00407bb5c052f92e49a1f6
This commit is contained in:
@@ -63,6 +63,7 @@ protected:
|
||||
KDCoordinate textHeight() const;
|
||||
KDCoordinate charWidth();
|
||||
void deleteCharPrecedingCursor();
|
||||
bool deleteEndOfLine();
|
||||
KDRect cursorRect();
|
||||
View * subviewAtIndex(int index) override;
|
||||
/* In some app (ie Calculation), text fields record expression results whose
|
||||
@@ -90,6 +91,7 @@ protected:
|
||||
ContentView m_contentView;
|
||||
private:
|
||||
void deleteCharPrecedingCursor();
|
||||
bool deleteEndOfLine();
|
||||
void scrollToCursor();
|
||||
bool m_hasTwoBuffers;
|
||||
TextFieldDelegate * m_delegate;
|
||||
|
||||
@@ -184,6 +184,17 @@ void TextField::ContentView::deleteCharPrecedingCursor() {
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
bool TextField::ContentView::deleteEndOfLine() {
|
||||
if (m_currentTextLength == m_currentCursorLocation) {
|
||||
return false;
|
||||
}
|
||||
reload();
|
||||
m_currentTextLength = m_currentCursorLocation;
|
||||
m_draftTextBuffer[m_currentCursorLocation] = 0;
|
||||
layoutSubviews();
|
||||
return true;
|
||||
}
|
||||
|
||||
KDRect TextField::ContentView::cursorRect() {
|
||||
return KDRect(m_currentCursorLocation * charWidth(), 0, m_cursorView.minimalSizeForOptimalDisplay());
|
||||
}
|
||||
@@ -299,6 +310,15 @@ void TextField::deleteCharPrecedingCursor() {
|
||||
layoutSubviews();
|
||||
}
|
||||
|
||||
bool TextField::deleteEndOfLine() {
|
||||
if (m_contentView.deleteEndOfLine()) {
|
||||
scrollToCursor();
|
||||
layoutSubviews();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
KDSize TextField::minimalSizeForOptimalDisplay() const {
|
||||
return KDSize(0, m_contentView.textHeight());
|
||||
}
|
||||
@@ -384,7 +404,9 @@ bool TextField::handleEvent(Ion::Events::Event event) {
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Clear && isEditing()) {
|
||||
setEditing(true, true);
|
||||
if (!deleteEndOfLine()) {
|
||||
setEditing(true, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Copy && !isEditing()) {
|
||||
|
||||
Reference in New Issue
Block a user