PopupMenuWindow grabs focus on mouseclick, but should not


#1

When you click on an item in a popupmenu the menu window grabs focus and the taskbar button of the currently active toplevelwindow gets deactivated until you release the mousebutton. This results in an annoying flash of the taskbar button when clicking on a menu item.

The PopupMenuWindow should set MouseClickGrabsKeyboardFocus to false in its constructor (like the MenuBarComponent does) to fix this problem.


#2

It’s supposed to be sorted out by marking the window as temporary. Which platform are you seeing this on? (I assume it’s a platform-specific issue)


#3

This happens at least on Windows (XP and Vista) and Linux (Ubuntu Hardy), have no Mac here to test there.

In the Windows windowing code is no special handling for the ComponentPeer::windowIsTemporary flag in the window creating code. In the Linux windowing code the _NET_WM_WINDOW_TYPE_MENU atom is set if ComponentPeer::windowIsTemporary flag is set. I would expect that to help but it doesn’t.

In the Windows windowing code these lines are the essential lines:

[code] case WM_MOUSEACTIVATE:
if (! component->getMouseClickGrabsKeyboardFocus())
return MA_NOACTIVATE;

                    break;[/code]

For Windows this effect can be reproduced using the JUCE demo. Just open any of the menus of the demo and click on a menu item, but don’t release the mouse button. As long as you hold the mouse button down the main demo windows taskbar button is not the active one, because the temporary menu windows got focus as you clicked on it. Setting MouseClickGrabsKeyboardFocus to false for the PopupMenuWindow solves this problem on windows, but not on Linux.


#4

Ok, thanks. I’ll see what I can do.


#5

I just noticed this in the Juce Demo app yesterday (on Windows 7).

Follow these steps:

  • choose the Widgets Demo
  • click (and release) on the “click for a popup menu” button
  • move the mouse down so that the “Tab position” submenu opens
  • move the mouse down a bit more to the next item (“AlertWindow demonstrations”)
    –> result = the taskbar button is un-highlighted.