Skip to content

Commit

Permalink
fix: window hide the menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
foamzou committed Jun 3, 2023
1 parent 4294f61 commit af9391a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ITrafficMonitorForMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
New,
);
LastSwiftUpdateCheck = 1210;
LastUpgradeCheck = 1210;
LastUpgradeCheck = 1340;
TargetAttributes = {
C4C9974926555B3A003ADDC2 = {
CreatedOnToolsVersion = 12.1.1;
Expand Down Expand Up @@ -353,9 +353,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ITrafficMonitorForMac/ITrafficMonitorForMac.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_ASSET_PATHS = "\"ITrafficMonitorForMac/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = ITrafficMonitorForMac/Info.plist;
Expand All @@ -364,7 +365,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.1.5;
MARKETING_VERSION = 0.1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.foamzou.ITrafficMonitorForMac;
PRODUCT_NAME = ITraffic;
SWIFT_VERSION = 5.0;
Expand All @@ -377,9 +378,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ITrafficMonitorForMac/ITrafficMonitorForMac.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_ASSET_PATHS = "\"ITrafficMonitorForMac/Preview Content\"";
ENABLE_PREVIEWS = YES;
INFOPLIST_FILE = ITrafficMonitorForMac/Info.plist;
Expand All @@ -388,7 +390,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.1.5;
MARKETING_VERSION = 0.1.6;
PRODUCT_BUNDLE_IDENTIFIER = com.foamzou.ITrafficMonitorForMac;
PRODUCT_NAME = ITraffic;
SWIFT_VERSION = 5.0;
Expand Down
12 changes: 12 additions & 0 deletions ITrafficMonitorForMac/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,20 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if globalModel.controllerHaveBeenReleased == true {
print("new controller")
AppDelegate.popover.contentViewController = NSHostingController(rootView: self.contentView.withGlobalEnvironmentObjects())
AppDelegate.popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY) // to avoid the child windows could not be create in the first time
}

if let parentWindow = NSApp.windows.first,
let popoverVCWindow = AppDelegate.popover.contentViewController?.view.window,
let childWindows = parentWindow.childWindows {
if !childWindows.contains(popoverVCWindow) {
parentWindow.addChildWindow(popoverVCWindow, ordered: .above)
}
} else {
print("Failed to add child window")
}


AppDelegate.popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY)
AppDelegate.popover.contentViewController?.view.viewDidMoveToWindow()
AppDelegate.popover.contentViewController?.view.window?.becomeKey()
Expand Down

0 comments on commit af9391a

Please sign in to comment.