Skip to content

Commit

Permalink
changed open position from center to mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
zaru committed Apr 10, 2020
1 parent 3d2b4b4 commit 1101c2b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 3 additions & 1 deletion menuffy/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 2 additions & 11 deletions menuffy/MainMenu/MenuWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -31,7 +23,6 @@ class MenuWindow: NSPanel {
self.makeKeyAndOrderFront(nil)
self.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
self.level = NSWindow.Level.floating

}

override var canBecomeKey: Bool {
Expand Down

0 comments on commit 1101c2b

Please sign in to comment.