Skip to content

Commit 84e9576

Browse files
committed
macOS: hide popups when window is resized (issue #1082)
1 parent 1a80a65 commit 84e9576

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ FlatLaf Change Log
1212
- Slider: Styling `thumbSize` or `focusWidth` did not update slider size/layout.
1313
(PR #1074)
1414
- ToolBar: Grip disappeared when switching between Look and Feels. (issue #1075)
15+
- macOS: Popups (menus and combobox lists) were not always hidden when window is
16+
resized. (issue #1082)
1517
- Extras:
1618
- UI defaults inspector: Fixed NPE if color of `FlatLineBorder` is null. Also
1719
use `FlatLineBorder` line color as cell background color in "Value" column.

flatlaf-core/src/main/java/com/formdev/flatlaf/FlatLaf.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ public void initialize() {
310310
// install submenu usability helper
311311
subMenuUsabilityHelperInstalled = SubMenuUsabilityHelper.install();
312312

313-
// install Linux popup menu canceler
314-
if( SystemInfo.isLinux )
313+
// install Linux/macOS popup menu canceler
314+
if( SystemInfo.isLinux || SystemInfo.isMacOS )
315315
linuxPopupMenuCanceler = new LinuxPopupMenuCanceler();
316316

317317
// listen to desktop property changes to update UI if system font or scaling changes

flatlaf-core/src/main/java/com/formdev/flatlaf/LinuxPopupMenuCanceler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import javax.swing.event.ChangeListener;
3131

3232
/**
33-
* Cancels (hides) popup menus on Linux.
33+
* Cancels (hides) popup menus on Linux and macOS.
3434
* <p>
3535
* On Linux, popups are not hidden under following conditions, which results in
3636
* misplaced popups:
@@ -41,7 +41,13 @@
4141
* <li>window deactivated (e.g. activated other application)
4242
* </ul>
4343
*
44-
* On Windows and macOS, popups are automatically hidden.
44+
* On macOS, popups are usually automatically hidden, but not always.
45+
* When resizing a window, then it depends where clicking to start resizing (and on the Java version).
46+
* E.g. with Java 25, clicking at bottom-right corner inside of the window does not hide the popups.
47+
* But clicking on same corner outside of the window, hides the popup.
48+
*
49+
* <p>
50+
* On Windows, popups are automatically hidden.
4551
* <p>
4652
* The implementation is similar to what's done in
4753
* {@code javax.swing.plaf.basic.BasicPopupMenuUI.MouseGrabber},

0 commit comments

Comments
 (0)