Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11, 5.15.7, 6.2.2
-
bbc3a7d7b (dev), 34740b936 (6.8), e7c8c2ccc (dev), 037e14dd0 (6.8)
Description
Currently it's not possible to react to e.g. a right click on a ToolButton in order to show a context menu.
In Photoshop, for example, you can long press on the button or right click it and it pops up a menu with more tools.
Another example is item delegates: in the Layers panel, you can right click on a delegate item to get a context menu with options for that layer.
Different platforms have different ways of triggering context menu events:
- Desktop platforms can trigger on mouse or key events, press or release
There are other areas that I'm not sure about but could conceivably be the case:
- A 5-key navigation UI could potentially show a menu for the selected item
- Touch platforms could show a context menu on long press
Users shouldn't need to deal with these differences, so having a contextMenuRequested() signal would be a good solution.
The documentation for QContextMenuEvent says:
Context menu events are sent to widgets when a user performs an action associated with opening a context menu. The actions required to open context menus vary between platforms; for example, on Windows, pressing the menu button or clicking the right mouse button will cause this event to be sent.
When this event occurs it is customary to show a QMenu with a context menu, if this is relevant to the context.
Context menu events contain a special accept flag that indicates whether the receiver accepted the event. If the event handler does not accept the event then, if possible, whatever triggered the event will be handled as a regular input event.
Attachments
Issue Links
- is required for
-
QTBUG-105531 Missing context menu for text fields
- In Progress
- relates to
-
QTBUG-35598 QtQuick Controls TextField and TextArea miss mouse context menu
- Open
-
QTBUG-60506 ItemDelegate should have an option to set captured mouse buttons
- Open
-
QTBUG-99887 TapHandler on TextField (for showing right click context menu) stops working in Qt6
- Closed
-
QTBUG-105609 should be able to add a TapHandler to a Button to modify behavior
- Closed
-
QTBUG-93486 Clean up delivery logic of QContextMenuEvent
- Reported
-
QTBUG-65951 Fusion style should offer TextField context menu
- Closed
-
QTBUG-67621 Add contextMenuRequested() signal to Control
- Closed
- resulted in
-
QTBUG-68105 Refactor context menu event handling
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTBUG-67331 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
554020,10 | WIP: Add ContextMenu | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |
555514,6 | QWindow: move context menu synthesis code into private virtual | dev | qt/qtbase | Status: NEW | 0 | 0 |
558655,13 | WIP: Add ContextMenu | dev | qt/qtdeclarative | Status: NEW | -2 | 0 |
226575,13 | WIP: AbstractButton: add rightClicked() signal | dev | qt/qtquickcontrols2 | Status: DEFERRED | -2 | 0 |
228008,1 | Add QQuickWindowPrivate as a friend of QCoreApplication | dev | qt/qtbase | Status: DEFERRED | 0 | 0 |
228011,12 | WIP: Send context menu events to items in Qt Quick | dev | qt/qtdeclarative | Status: ABANDONED | -2 | 0 |
597163,5 | qwsi: Teach handleContextMenuEvent about synchronous delivery | dev | qt/qtbase | Status: MERGED | +2 | 0 |
597187,4 | macOS: Add support for context menu keyboard hotkey | dev | qt/qtbase | Status: MERGED | +2 | 0 |
597659,2 | qwsi: Teach handleContextMenuEvent about synchronous delivery | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |
598981,2 | macOS: Add support for context menu keyboard hotkey | 6.8 | qt/qtbase | Status: MERGED | +2 | 0 |