Don't use TapHandlers in TextArea/TextField

Causes conflicts on touch/pen which prevent the component from being
focused. Use the normal press/pressHold signals instead.
This commit is contained in:
miruka 2020-08-23 15:41:20 -04:00
parent 71a2951f5b
commit 7502c1a9b4
2 changed files with 6 additions and 22 deletions

View File

@ -107,6 +107,9 @@ TextArea {
previousDefaultText = defaultText previousDefaultText = defaultText
} }
onPressed: ev => { if (ev.button === Qt.RightButton) contextMenu.spawn() }
onPressAndHold: ev => contextMenu.spawn()
Keys.onPressed: ev => { Keys.onPressed: ev => {
// Prevent alt/super+any key from typing text // Prevent alt/super+any key from typing text
if ( if (
@ -181,17 +184,6 @@ TextArea {
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
} }
TapHandler {
acceptedButtons: Qt.RightButton
acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Pen
onTapped: contextMenu.spawn()
}
TapHandler {
acceptedPointerTypes: PointerDevice.Finger | PointerDevice.Pen
onLongPressed: contextMenu.spawn()
}
HTextContextMenu { HTextContextMenu {
id: contextMenu id: contextMenu
enableCustomImagePaste: textArea.enableCustomImagePaste enableCustomImagePaste: textArea.enableCustomImagePaste

View File

@ -87,6 +87,9 @@ TextField {
previousDefaultText = defaultText previousDefaultText = defaultText
} }
onPressed: ev => { if (ev.button === Qt.RightButton) contextMenu.spawn() }
onPressAndHold: ev => contextMenu.spawn()
// Prevent alt/super+any key from typing text // Prevent alt/super+any key from typing text
Keys.onPressed: if ( Keys.onPressed: if (
event.modifiers & Qt.AltModifier || event.modifiers & Qt.AltModifier ||
@ -146,16 +149,5 @@ TextField {
Behavior on opacity { HNumberAnimation {} } Behavior on opacity { HNumberAnimation {} }
} }
TapHandler {
acceptedButtons: Qt.RightButton
acceptedPointerTypes: PointerDevice.GenericPointer | PointerDevice.Pen
onTapped: contextMenu.spawn()
}
TapHandler {
acceptedPointerTypes: PointerDevice.Finger | PointerDevice.Pen
onLongPressed: contextMenu.spawn()
}
HTextContextMenu { id: contextMenu } HTextContextMenu { id: contextMenu }
} }