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

Accidential activation of items in context menus

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.1.0
    • GUI: Look'n'Feel
    • None

    Description

      Description:

      When opening and immediately closing a context menu by doing two right-clicks without moving the mouse pointer in between, Qt5 currently selects the first item of the context menu.

      Expected behavior:

      I would expect that the second mouse click simply closes the menu without activating an item.

      Actual behavior:

      The first item of the context menu is activated, probably without user intention.

      Regression:

      I think this is a usability issue since many users will probably activate items in the context menu without intending so. I examined the behavior on different systems (Windows 7, OSX, other Linux Desktops), they all simply close a context menu on the second mouse click.

      Steps to reproduce:

      • build a sample project containing a widget that handles
        the context-menu event (see code-snippet nelow)
      • position mouse in this widget and hold the mouse still,
        i.e. the mouse pointer shall not move
      • right click on the mouse to open a context menu
      • right click again

      => the first action of the menu is activated

      Example codesnippet:

      void Widget::contextMenuEvent (QContextMenuEvent *event)
      {
      QPoint where (event->globalPos ());
      QMenu menu;
      ... // build menu contents
      QAction *selectedAction = menu.exec (where);
      ...
      }

      Workaround / possible solution:

      I would suggest to translate the given position for the menu by 1 pixel in x and y direction and opening the menu at the translated position. So the mouse pointer is not hovering the first menu item.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            1337_michael Michael Schmidt
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes