Component::focusLost() is called before handling menu select

Hi Jules,

I found a problem on Windows.

When choosing a menu item, Component::focusLost() is called before handling the menu item. This is a problem.

For example, I have a component and a menu item in menu bar. The menu item is enabled only while the component has keyboard focus. So I override focusGained() and focusLost() to control the status of the item in the menu bar.

While the component has keyboard focus,

On Windows case 1 (NG):

  • Press the mouse button on the menu bar then the menu is shown, and release the mouse button.
  • Move the mouse cursor on the menu item, then click it.
  • MyComponent::focusLost() is called, then change the menu status to set the item disabled.
  • MyWindow::perform() never been called because the menu is disabled.

On Windows case 2 (OK):

  • Press the mouse button on the menu bar then the menu is shown, holding the mouse button.
  • Move the mouse cursor on the menu item, then release the mouse button.
  • MyWindow::perform() is called then do the menu item handling.
  • MyComponent::focusLost() is called, then change the menu status.

On Mac (OK):

  • Press the mouse button on the menu bar then the menu is shown, and release the mouse button.
  • Move the mouse cursor on the menu item, then click it.
  • MyWindow::perform() is called then do the menu item handling.
  • MyComponent::focusLost() is called, then change the menu status.

Could you change the behavior of the first case to the same as other cases? Or should I change the menu item status in other way or timing?

Best regards,
Masanao Hayashi