macOS: hide popups when window is resized (issue #1082)

This commit is contained in:
Karl Tauber
2026-01-30 19:01:26 +01:00
parent 1a80a65411
commit 84e95764fa
3 changed files with 12 additions and 4 deletions

View File

@@ -12,6 +12,8 @@ FlatLaf Change Log
- Slider: Styling `thumbSize` or `focusWidth` did not update slider size/layout. - Slider: Styling `thumbSize` or `focusWidth` did not update slider size/layout.
(PR #1074) (PR #1074)
- ToolBar: Grip disappeared when switching between Look and Feels. (issue #1075) - ToolBar: Grip disappeared when switching between Look and Feels. (issue #1075)
- macOS: Popups (menus and combobox lists) were not always hidden when window is
resized. (issue #1082)
- Extras: - Extras:
- UI defaults inspector: Fixed NPE if color of `FlatLineBorder` is null. Also - UI defaults inspector: Fixed NPE if color of `FlatLineBorder` is null. Also
use `FlatLineBorder` line color as cell background color in "Value" column. use `FlatLineBorder` line color as cell background color in "Value" column.

View File

@@ -310,8 +310,8 @@ public abstract class FlatLaf
// install submenu usability helper // install submenu usability helper
subMenuUsabilityHelperInstalled = SubMenuUsabilityHelper.install(); subMenuUsabilityHelperInstalled = SubMenuUsabilityHelper.install();
// install Linux popup menu canceler // install Linux/macOS popup menu canceler
if( SystemInfo.isLinux ) if( SystemInfo.isLinux || SystemInfo.isMacOS )
linuxPopupMenuCanceler = new LinuxPopupMenuCanceler(); linuxPopupMenuCanceler = new LinuxPopupMenuCanceler();
// listen to desktop property changes to update UI if system font or scaling changes // listen to desktop property changes to update UI if system font or scaling changes

View File

@@ -30,7 +30,7 @@ import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
/** /**
* Cancels (hides) popup menus on Linux. * Cancels (hides) popup menus on Linux and macOS.
* <p> * <p>
* On Linux, popups are not hidden under following conditions, which results in * On Linux, popups are not hidden under following conditions, which results in
* misplaced popups: * misplaced popups:
@@ -41,7 +41,13 @@ import javax.swing.event.ChangeListener;
* <li>window deactivated (e.g. activated other application) * <li>window deactivated (e.g. activated other application)
* </ul> * </ul>
* *
* On Windows and macOS, popups are automatically hidden. * On macOS, popups are usually automatically hidden, but not always.
* When resizing a window, then it depends where clicking to start resizing (and on the Java version).
* E.g. with Java 25, clicking at bottom-right corner inside of the window does not hide the popups.
* But clicking on same corner outside of the window, hides the popup.
*
* <p>
* On Windows, popups are automatically hidden.
* <p> * <p>
* The implementation is similar to what's done in * The implementation is similar to what's done in
* {@code javax.swing.plaf.basic.BasicPopupMenuUI.MouseGrabber}, * {@code javax.swing.plaf.basic.BasicPopupMenuUI.MouseGrabber},