Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
5.2.0
-
e426737d7 (dev), 56c39a262 (6.9), 3b598b6f7 (dev), dfcde3ea4 (6.9)
Description
Native applications are expected to offer a context menu for input fields.
This is currently missing from QtQuick controls.
The example code below was my implementation for QtQuick 1.1. Though it should be easy to port this to QtQuick 2, I would have expected this to work out of the box.
import QtQuick 1.1 import QtDesktop 0.1 as Desktop MouseArea { id: editorContextMenu property Item editor signal menuShown anchors.fill: parent acceptedButtons: Qt.RightButton onPressed: { // selection gets lost due to focus loss var selectionStart = editor.selectionStart var selectionEnd = editor.selectionEnd var pos = mapToItem(null, mouseX, mouseY) menuLoader.sourceComponent = menuComponent menuLoader.item.showPopup(pos.x, pos.y) editor.select(selectionStart, selectionEnd) menuShown() } Component { id: menuComponent // Desktop.ContextMenu kann nicht direkt im Loader benutzt werden, da kein Item Item { function showPopup(x, y) { editmenu.showPopup(x, y) } Desktop.ContextMenu { id: editmenu onMenuClosed: menuLoader.sourceComponent = null Desktop.MenuItem { text: qsTr("cut") onTriggered: editor.cut() enabled: editor.selectedText.length > 0 } Desktop.MenuItem { text: qsTr("copy") onTriggered: editor.copy() enabled: editor.selectedText.length > 0 } Desktop.MenuItem { text: qsTr("paste") onTriggered: editor.paste() enabled: editor.canPaste } } } } Loader { id: menuLoader } }
Attachments
Issue Links
- depends on
-
QTBUG-133424 Named platform icons are blurry on macOS when displayed with IconImage/IconLabel
-
- In Progress
-
-
QTBUG-133302 ContextMenu opened on TextField sometimes closes immediately
-
- Closed
-
-
QTBUG-132265 Defer creation of Menu until it's shown
-
- Closed
-
- is duplicated by
-
QTBUG-105531 Missing context menu for text fields
-
- Closed
-
- relates to
-
QTBUG-132422 Mouse cursor is I beam instead of arrow when opening menu in window-based popup over text editing control
-
- Reported
-
-
QTBUG-99887 TapHandler on TextField (for showing right click context menu) stops working in Qt6
-
- Closed
-
-
QTBUG-133556 Allow disabling built-in ContextMenus of TextField and TextArea with a global flag
-
- Reported
-
-
QTBUG-67331 Make it possible to react to context menu events
-
- Closed
-
-
QTBUG-67621 Add contextMenuRequested() signal to Control
-
- Closed
-
For Gerrit Dashboard: QTBUG-35598 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
624915,9 | Internally document ContextMenu's event delivery on iOS | dev | qt/qtdeclarative | Status: NEW | 0 | 0 |
627951,2 | Doc: Update ContextMenu What's New in Qt 6.9 | dev | qt/qtdoc | Status: NEW | +2 | 0 |
630179,2 | ContextMenu: add undo and redo | dev | qt/qtdeclarative | Status: NEW | 0 | 0 |
612253,82 | ContextMenu: add to text editing controls | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
618449,7 | iOS: send context menu event rather than instantly showing edit menu | dev | qt/qtbase | Status: MERGED | +2 | 0 |
622448,2 | iOS: send context menu event rather than instantly showing edit menu | 6.9 | qt/qtbase | Status: MERGED | +2 | 0 |
627943,2 | ContextMenu: add to text editing controls | 6.9 | qt/qtdeclarative | Status: MERGED | +2 | 0 |