Skip to content

Commit

Permalink
add quit button and placeholder for Preferences/Options
Browse files Browse the repository at this point in the history
  • Loading branch information
dshnkao committed Feb 6, 2017
1 parent d922f96 commit 9c0c6e3
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions SpaceId/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {

let statusItem = NSStatusBar.system().statusItem(withLength: 27)

@IBOutlet weak var statusMenu: NSMenu!

let statusItem = NSStatusBar.system().statusItem(withLength: 27)
let spaceIdentifier = SpaceIdentifier()
let buttonImage = ButtonImage()

Expand All @@ -13,6 +14,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
addActiveWorkSpaceEvent()
addActiveApplicationEvent()
addLeftMouseClickEvent()
addMenuItems()
updateSpaceNumber(())
}

Expand Down Expand Up @@ -49,5 +51,18 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
private func addLeftMouseClickEvent() {
NSEvent.addGlobalMonitorForEvents(matching: NSEventMask.leftMouseDown, handler: updateSpaceNumber)
}

private func addMenuItems() {
let menu = NSMenu()
menu.addItem(NSMenuItem(title: "Preferences", action: nil, keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "Options", action: nil, keyEquivalent: ""))
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: "Quit", action: #selector(quitButton(_:)), keyEquivalent: ""))
statusItem.menu = menu
}

func quitButton(_ sender: NSMenuItem) {
NSApplication.shared().terminate(self)
}
}

0 comments on commit 9c0c6e3

Please sign in to comment.