Open
Description
Issue
If I try running the example code but remove the following lines:
diff --git a/example/lib/pages/home.dart b/example/lib/pages/home.dart
index 75c3c1e..e566590 100644
--- a/example/lib/pages/home.dart
+++ b/example/lib/pages/home.dart
@@ -185,8 +185,8 @@ class _HomePageState extends State<HomePage> with TrayListener, WindowListener {
onTap: () async {
await windowManager.hide();
await Future.delayed(const Duration(seconds: 2));
- await windowManager.show();
- await windowManager.focus();
},
),
PreferenceListItem(
the window stays hidden when pressing show/hide
. I then do the following:
- press the
show/hide
button. The app is now hidden. - right-click on the icon down in the dock on macOS. A menu will appear with several items.
- In the menu one of the options is to hide the app. However, the app is already hidden, because I pressed
show/hide
. I would expect to get the option to show the app. This means that macOS does not entirely understand what happens when we callhide()
.
Solution
If I change to the following in WindowManager.swift
public func hide() {
DispatchQueue.main.async {
NSApp.hide(nil)
}
}
It seems to fix the problem. Now, when I press show/hide
and the app is hidden, I get the option to show the app when right-clicking on the icon in the dock on macOS.