Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8354539

[macOS] ComboBox and Spinner disable system menu bar shortcuts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • jfx24
    • javafx

      Accelerators in the system menu bar do not work If the focus is in a ComboBox, DatePicker, or Spinner. These skins work by consuming the original key event and firing a new one at an internal TextField. Because the original event was consumed glass believes that the key was processed and doesn’t pass it on to the system menus. The key event fired at the TextField doesn’t trigger menu accelerators since the system menu bar works entirely outside the scene graph.

      This behavior is new in JavaFX 24. In previous releases key events consumed by the scene graph were also passed to the system menu bar. This caused bugs where the same accelerator was acted on twice.

      Note that the Quit menu item (Cmd+Q) is affected even in apps that don’t enable the system menu bar. The application menu is always implemented using the system menu bar.

      The ComboBoxes and Spinners are firing a key event and assuming it will eventually make its way up to the Scene and invoke menu accelerators. I don’t think these controls are doing anything wrong but one possible fix for this is to find a new way of implementing this event forwarding behavior.

      Another approach would be to ensure the system menu bar processes accelerators at the same time that a regular MenuBar does and under the same conditions. In other words, if a KeyEvent makes its way to a Scene it could call back into Glass to give it a chance to process the event as a menu accelerator. In the PR for JDK-8087863 I said that this would be tricky but it might be time to explore this idea in more detail.

      To reproduce, run the attached test file and try to use Cmd+W to toggle the checkbox. This will work if focus is in the top text field but not if it’s in a ComboBox, DatePicker, or Spinner.

            mfox Martin Fox
            mfox Martin Fox
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: