diff --git a/menuffy/AppDelegate.swift b/menuffy/AppDelegate.swift index 0bb705e..85a5652 100644 --- a/menuffy/AppDelegate.swift +++ b/menuffy/AppDelegate.swift @@ -64,7 +64,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { let app = activeApp() let pid = app.processIdentifier - menuWindow = MenuWindow() + let location = NSEvent.mouseLocation + menuWindow = MenuWindow(locationX: location.x, locationY: location.y) + menuView = MenuView() menuView.appMenu.delegate = self menuWindow.contentView?.addSubview(menuView) diff --git a/menuffy/MainMenu/MenuWindow.swift b/menuffy/MainMenu/MenuWindow.swift index c5cb6b9..b182dd8 100644 --- a/menuffy/MainMenu/MenuWindow.swift +++ b/menuffy/MainMenu/MenuWindow.swift @@ -11,16 +11,8 @@ import Cocoa // NSWindow だと NSTextField が active にならないので NSPanel にする class MenuWindow: NSPanel { - override init(contentRect: NSRect, - styleMask style: NSWindow.StyleMask, - backing backingStoreType: NSWindow.BackingStoreType, - defer flag: Bool) { - - let screenFrame = NSScreen.main!.frame - let menuX = screenFrame.width / 2 - 100 - let menuY = screenFrame.height / 2 + 100 - - super.init(contentRect: NSRect(x: menuX, y: menuY, width: 200, height: 50), + init(locationX: CGFloat, locationY: CGFloat) { + super.init(contentRect: NSRect(x: locationX, y: locationY, width: 200, height: 50), styleMask: [.nonactivatingPanel], backing: .buffered, defer: false) @@ -31,7 +23,6 @@ class MenuWindow: NSPanel { self.makeKeyAndOrderFront(nil) self.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] self.level = NSWindow.Level.floating - } override var canBecomeKey: Bool {