Compare commits

...

1 Commits

Author SHA1 Message Date
vkamn cfe8641fd8 fix: context menu fixes for qt6.9 2025-11-20 10:10:49 +08:00
4 changed files with 9 additions and 44 deletions
+4 -7
View File
@@ -1,33 +1,30 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import Qt.labs.platform
Menu { Menu {
property var textObj property var textObj
popupType: Popup.Native
MenuItem { MenuItem {
text: qsTr("C&ut") text: qsTr("C&ut")
shortcut: StandardKey.Cut
enabled: textObj.selectedText enabled: textObj.selectedText
onTriggered: textObj.cut() onTriggered: textObj.cut()
} }
MenuItem { MenuItem {
text: qsTr("&Copy") text: qsTr("&Copy")
shortcut: StandardKey.Copy
enabled: textObj.selectedText enabled: textObj.selectedText
onTriggered: textObj.copy() onTriggered: textObj.copy()
} }
MenuItem { MenuItem {
text: qsTr("&Paste") text: qsTr("&Paste")
shortcut: StandardKey.Paste // Fix calling paste from clipboard when launching app on android
// Fix calling paste from clipboard when launching app on android/ios enabled: Qt.platform.os === "android" ? true : textObj.canPaste
enabled: (Qt.platform.os === "android" || Qt.platform.os === "ios") ? true : textObj.canPaste
onTriggered: textObj.paste() onTriggered: textObj.paste()
} }
MenuItem { MenuItem {
text: qsTr("&SelectAll") text: qsTr("&SelectAll")
shortcut: StandardKey.SelectAll
enabled: textObj.length > 0 enabled: textObj.length > 0
onTriggered: textObj.selectAll() onTriggered: textObj.selectAll()
} }
+2 -14
View File
@@ -93,25 +93,13 @@ Rectangle {
wrapMode: Text.Wrap wrapMode: Text.Wrap
MouseArea { ContextMenu.menu: ContextMenuType {
id: textAreaMouse textObj: textArea
anchors.fill: parent
acceptedButtons: Qt.RightButton
hoverEnabled: true
onClicked: {
fl.interactive = true
contextMenu.open()
}
} }
onFocusChanged: { onFocusChanged: {
root.border.color = getBorderColor(borderNormalColor) root.border.color = getBorderColor(borderNormalColor)
} }
ContextMenuType {
id: contextMenu
textObj: textArea
}
} }
} }
@@ -79,25 +79,13 @@ Rectangle {
wrapMode: Text.Wrap wrapMode: Text.Wrap
MouseArea { ContextMenu.menu: ContextMenuType {
id: textAreaMouse textObj: textArea
anchors.fill: parent
acceptedButtons: Qt.RightButton
hoverEnabled: true
onClicked: {
fl.interactive = true
contextMenu.open()
}
} }
onFocusChanged: { onFocusChanged: {
root.border.color = getBorderColor(borderNormalColor) root.border.color = getBorderColor(borderNormalColor)
} }
ContextMenuType {
id: contextMenu
textObj: textArea
}
} }
RowLayout { RowLayout {
@@ -137,15 +137,7 @@ Item {
} }
} }
MouseArea { ContextMenu.menu: ContextMenuType {
anchors.fill: parent
acceptedButtons: Qt.RightButton
onClicked: contextMenu.open()
enabled: true
}
ContextMenuType {
id: contextMenu
textObj: textField textObj: textField
} }