ChatBar: Remove explicit Keys.onDeletePressed handler
Key-specific handlers, such as Key.onDeletePressed implicitly accept the event. This means that the entire logic for the delete key must be reimplemented, and e.g. Ctrl+Delete to delete the previous *word* was missed. Since all it has to do is handle the typing notification and format bar, just use the already existing Keys.onPressed handler (which does *not* accept the event) and add a case for Delete alongside Backspace.
This commit is contained in:
@@ -237,20 +237,6 @@ QQC2.Control {
|
|||||||
onFormattingSelected: _private.formatText(format, selectionStart, selectionEnd)
|
onFormattingSelected: _private.formatText(format, selectionStart, selectionEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onDeletePressed: {
|
|
||||||
if (selectedText.length > 0) {
|
|
||||||
remove(selectionStart, selectionEnd);
|
|
||||||
} else {
|
|
||||||
remove(cursorPosition, cursorPosition + 1);
|
|
||||||
}
|
|
||||||
if (textField.text == selectedText || textField.text.length <= 1) {
|
|
||||||
root.currentRoom.sendTypingNotification(false);
|
|
||||||
repeatTimer.stop();
|
|
||||||
}
|
|
||||||
if (quickFormatBar.visible) {
|
|
||||||
quickFormatBar.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Keys.onEnterPressed: event => {
|
Keys.onEnterPressed: event => {
|
||||||
const controlIsPressed = event.modifiers & Qt.ControlModifier;
|
const controlIsPressed = event.modifiers & Qt.ControlModifier;
|
||||||
if (completionMenu.visible) {
|
if (completionMenu.visible) {
|
||||||
@@ -289,7 +275,7 @@ QQC2.Control {
|
|||||||
completionMenu.decrementIndex();
|
completionMenu.decrementIndex();
|
||||||
} else if (event.key === Qt.Key_Down && completionMenu.visible) {
|
} else if (event.key === Qt.Key_Down && completionMenu.visible) {
|
||||||
completionMenu.incrementIndex();
|
completionMenu.incrementIndex();
|
||||||
} else if (event.key === Qt.Key_Backspace) {
|
} else if (event.key === Qt.Key_Backspace || event.key === Qt.Key_Delete) {
|
||||||
if (textField.text == selectedText || textField.text.length <= 1) {
|
if (textField.text == selectedText || textField.text.length <= 1) {
|
||||||
root.currentRoom.sendTypingNotification(false);
|
root.currentRoom.sendTypingNotification(false);
|
||||||
repeatTimer.stop();
|
repeatTimer.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user