Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11, 5.15.7, 6.2.2
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
- relates to
-
QTBUG-35598 QtQuick Controls TextField and TextArea miss mouse context menu
- Open
-
QTBUG-105531 Missing context menu for text fields
- Reported
-
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-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