Skip to content

Commit

Permalink
[hotfix] Update way to quit the app (#20)
Browse files Browse the repository at this point in the history
- Click to seperator button to show menu
- Click to expanseCollapse button to expand or collapse menu bar
  • Loading branch information
phucledien authored Dec 10, 2019
1 parent 06aef95 commit b556aae
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions hidden/ViewControlllers/StatusBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ class StatusBarController{

func initView(){

appMenu = setupMenuUI()

if let button = seprateStatusBar.button {
button.image = NSImage(named:NSImage.Name("ic_line"))
}

appMenu = setupMenuUI()
seprateStatusBar.menu = appMenu

if let button = expandCollapseStatusBar.button {
button.image = NSImage(named:NSImage.Name("ic_collapse"))
btnDot = NSStatusBarButton.collapseBarButtonItem()
btnDot?.target = self
btnDot?.action = #selector(statusBarButtonClicked(_:))
button.addSubview(btnDot!)
button.target = self
button.action = #selector(expandCollapseIfNeeded(_:))
}


Expand All @@ -58,30 +58,7 @@ class StatusBarController{
return Float((expandCollapseStatusBar.button?.getOrigin!.x)!) > Float((seprateStatusBar.button?.getOrigin!.x)!)
}

@objc func statusBarButtonClicked(_ sender: NSStatusBarButton) {
let event = NSApp.currentEvent!

if event.type == NSEvent.EventType.rightMouseUp {
openAppMenu()
} else {
expandCollapseIfNeeded()
}
}

private func openAppMenu()
{
if (appMenu != nil)
{
expandCollapseStatusBar.menu = appMenu //set the menu

let p = NSPoint(x: 0,
y: (expandCollapseStatusBar.statusBar?.thickness)!)
self.appMenu!.popUp(positioning: self.appMenu!.item(at: 0), at:p , in: btnDot)

}
}

@objc func expandCollapseIfNeeded() {
@objc func expandCollapseIfNeeded(_ sender: NSStatusBarButton) {
if(isValidPosition())
{
if isToggle == false {
Expand Down

0 comments on commit b556aae

Please sign in to comment.