mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[escher/text_field] Fix privateHandleEvent text reset
This commit is contained in:
@@ -7,9 +7,9 @@ class TextFieldDelegate {
|
||||
public:
|
||||
virtual bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) = 0;
|
||||
virtual bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) = 0;
|
||||
virtual bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) { return false; };
|
||||
virtual bool textFieldDidAbortEditing(TextField * textField) {return false;};
|
||||
virtual bool textFieldDidHandleEvent(TextField * textField, bool returnValue, bool textSizeDidChange) { return returnValue; };
|
||||
virtual bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) { return false; }
|
||||
virtual bool textFieldDidAbortEditing(TextField * textField) { return false; }
|
||||
virtual bool textFieldDidHandleEvent(TextField * textField, bool returnValue, bool textSizeDidChange) { return returnValue; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -262,7 +262,7 @@ bool TextField::privateHandleEvent(Ion::Events::Event event) {
|
||||
* This will call textFieldDidAbortEditing if the textfield is still editing,
|
||||
* which we do not want, as we are not really aborting edition, just
|
||||
* displaying a pop-up before returning to edition.
|
||||
* We thus set editiong to false. */
|
||||
* We thus set editing to false. */
|
||||
setEditing(false, m_hasTwoBuffers);
|
||||
if (m_delegate->textFieldDidFinishEditing(this, text(), event)) {
|
||||
/* We allow overscroll to avoid calling layoutSubviews twice because the
|
||||
@@ -270,14 +270,12 @@ bool TextField::privateHandleEvent(Ion::Events::Event event) {
|
||||
reloadScroll(true);
|
||||
return true;
|
||||
}
|
||||
setEditing(true, m_hasTwoBuffers);
|
||||
setEditing(true, false);
|
||||
if (m_hasTwoBuffers) {
|
||||
/* if the text was refused (textInputDidFinishEditing returned false, we
|
||||
* reset the textfield in the same state as before */
|
||||
char bufferDraft[ContentView::k_maxBufferSize];
|
||||
strlcpy(bufferDraft, m_contentView.textBuffer(), ContentView::k_maxBufferSize);
|
||||
setText(bufferText);
|
||||
setText(bufferDraft);
|
||||
setText(m_contentView.textBuffer());
|
||||
strlcpy(m_contentView.textBuffer(), bufferText, ContentView::k_maxBufferSize);
|
||||
setCursorLocation(cursorLoc);
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user