mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[escher/text_field] Fix cut event text deletion
If there is a Cut event and the text field is edited but there is no selection, the text is not stored in the clipboard but it was still deleted.
This commit is contained in:
@@ -91,7 +91,7 @@ private:
|
||||
bool privateHandleMoveEvent(Ion::Events::Event event);
|
||||
bool privateHandleSelectEvent(Ion::Events::Event event);
|
||||
virtual void removeWholeText();
|
||||
void storeInClipboard() const;
|
||||
bool storeInClipboard() const;
|
||||
TextFieldDelegate * m_delegate;
|
||||
};
|
||||
|
||||
|
||||
@@ -358,8 +358,7 @@ bool TextField::privateHandleEvent(Ion::Events::Event event) {
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::Copy || event == Ion::Events::Cut) {
|
||||
storeInClipboard();
|
||||
if (event == Ion::Events::Cut) {
|
||||
if (storeInClipboard() && event == Ion::Events::Cut) {
|
||||
if (!m_contentView.selectionIsEmpty()) {
|
||||
deleteSelection();
|
||||
} else {
|
||||
@@ -542,11 +541,14 @@ void TextField::removeWholeText() {
|
||||
reloadScroll();
|
||||
}
|
||||
|
||||
void TextField::storeInClipboard() const {
|
||||
bool TextField::storeInClipboard() const {
|
||||
if (!isEditing()) {
|
||||
Clipboard::sharedClipboard()->store(text());
|
||||
return true;
|
||||
} else if (!m_contentView.selectionIsEmpty()) {
|
||||
const char * start = m_contentView.selectionStart();
|
||||
Clipboard::sharedClipboard()->store(start, m_contentView.selectionEnd() - start);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user