Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-67331

Make it possible to react to context menu events

    XMLWordPrintable

Details

    • bbc3a7d7b (dev), 34740b936 (6.8), e7c8c2ccc (dev), 037e14dd0 (6.8), 9f75fe29d (dev), 70c61b12e (dev), 019feea9b (6.9), 0794a0e06 (dev)

    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:

      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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              mitch_curtis Mitch Curtis
              mitch_curtis Mitch Curtis
              Votes:
              5 Vote for this issue
              Watchers:
              13 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: