         
         super.init()
         
-        self.statusItemView.mouseDownHandler = {
-            if self.popover.shown {
-                self.hidePopover()
-            } else {
-                self.showPopover()
-            }
-        }
+        self.statusItem.target = self
+        self.statusItem.action = "showPopover"
+
+        NSEvent.addGlobalMonitorForEventsMatchingMask(.LeftMouseUpMask | .LeftMouseDownMask, handler: {
+            event in
+            self.hidePopover()
+        })
+        
+//        self.statusItemView.mouseDownHandler = {
+//            if self.popover.shown {
+//                self.hidePopover()
+//            } else {
+//                self.showPopover()
+//            }
+//        }
     }
     
     func showPopover(animated: Bool) {
-        self.statusItemView.active = true
-        self.statusItemView.needsDisplay = true
-        
-        if self.popover.shown == false {
-            if self.popoverWillShowHandler != nil {
-                self.popoverWillShowHandler!()
-            }
-            
-            //NSApplication.sharedApplication().activateIgnoringOtherApps(true)
-            
-            self.popover.animates = animated
-            self.popover.contentSize = self.viewController.view.frame.size
-            self.statusItem.popUpStatusItemMenu(self.dummyMenu)
-            
-            self.popover.showRelativeToRect(self.statusItemView.frame, ofView: self.statusItemView, preferredEdge: NSMinYEdge)
-            
-            let mask: NSEventMask = .LeftMouseDownMask | .RightMouseDownMask  // FIXME: Bypassing Link Error
-            self.popoverTouchHandler = NSEvent.addGlobalMonitorForEventsMatchingMask(mask, handler: { (event: NSEvent!) -> Void in
-                self.hidePopover()
-            })
-
-        }
+        if self.popover.shown {
+            self.popover.close()
+            return
+        }
+        
+//        self.statusItemView.active = true
+//        self.statusItemView.needsDisplay = true
+        
+        if self.popoverWillShowHandler != nil {
+            self.popoverWillShowHandler!()
+        }
+        
+        self.statusItemButton.state = NSOnState
+        NSApp.activateIgnoringOtherApps(true)
+        
+        self.popover.animates = animated
+        self.popover.contentSize = self.viewController.view.frame.size
+        self.popover.showRelativeToRect(NSZeroRect, ofView: self.statusItemButton, preferredEdge: NSMaxYEdge)
+
+//        if self.popover.shown == false {
+//            if self.popoverWillShowHandler != nil {
+//                self.popoverWillShowHandler!()
+//            }
+//            
+//            //NSApplication.sharedApplication().activateIgnoringOtherApps(true)
+//            
+//            self.popover.animates = animated
+//            self.popover.contentSize = self.viewController.view.frame.size
+//            self.statusItem.popUpStatusItemMenu(self.dummyMenu)
+//            
+//            self.popover.showRelativeToRect(self.statusItemView.frame, ofView: self.statusItemView, preferredEdge: NSMinYEdge)
+//            
+//            let mask: NSEventMask = .LeftMouseDownMask | .RightMouseDownMask  // FIXME: Bypassing Link Error
+//            self.popoverTouchHandler = NSEvent.addGlobalMonitorForEventsMatchingMask(mask, handler: { (event: NSEvent!) -> Void in
+//                self.hidePopover()
+//            })
+//
+//        }
     }
     
     func showPopover() {

        //NSApp.setActivationPolicy(NSApplicationActivationPolicy.Prohibited)
        self.viewController = viewController
        
        let height = NSStatusBar.systemStatusBar().thickness
        self.statusItemView = SRStatusItemPopupView(frame: NSMakeRect(0, 0, self.minWidth, height))
        self.statusItemView.image = image
        self.statusItemView.alternateImage = alternateImage
        
        let thickness = NSStatusBar.systemStatusBar().thickness
        self.statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(thickness)    // FIXME: -1.0 = NSVariableStatusItemLength (bypassing undefined symbol link error)
        self.statusItem.view = self.statusItemView
        
        self.dummyMenu = NSMenu()
        
        self.popover = NSPopover()
        self.popover.contentViewController = self.viewController

    }
    
    func hidePopover() {
        if self.popover.shown == false { return }
        
        self.statusItemButton.state = NSOffState
        self.popover.close()
//        self.statusItemView.active = false
//        self.statusItemView.needsDisplay = true
        
//        if self.popover.shown {
//            self.popover.close()
//            
//            if self.popoverTouchHandler != nil {
//                NSEvent.removeMonitor(self.popoverTouchHandler!)
//                self.popoverTouchHandler = nil
//            }
//        }
    }
}

