@@ -22,18 +22,18 @@ class StatusBarController{
22
22
23
23
func initView( ) {
24
24
25
- appMenu = setupMenuUI ( )
26
25
27
26
if let button = seprateStatusBar. button {
28
27
button. image = NSImage ( named: NSImage . Name ( " ic_line " ) )
29
28
}
30
29
30
+ appMenu = setupMenuUI ( )
31
+ seprateStatusBar. menu = appMenu
32
+
31
33
if let button = expandCollapseStatusBar. button {
32
34
button. image = NSImage ( named: NSImage . Name ( " ic_collapse " ) )
33
- btnDot = NSStatusBarButton . collapseBarButtonItem ( )
34
- btnDot? . target = self
35
- btnDot? . action = #selector( statusBarButtonClicked ( _: ) )
36
- button. addSubview ( btnDot!)
35
+ button. target = self
36
+ button. action = #selector( expandCollapseIfNeeded ( _: ) )
37
37
}
38
38
39
39
@@ -58,30 +58,7 @@ class StatusBarController{
58
58
return Float ( ( expandCollapseStatusBar. button? . getOrigin!. x) !) > Float ( ( seprateStatusBar. button? . getOrigin!. x) !)
59
59
}
60
60
61
- @objc func statusBarButtonClicked( _ sender: NSStatusBarButton ) {
62
- let event = NSApp . currentEvent!
63
-
64
- if event. type == NSEvent . EventType. rightMouseUp {
65
- openAppMenu ( )
66
- } else {
67
- expandCollapseIfNeeded ( )
68
- }
69
- }
70
-
71
- private func openAppMenu( )
72
- {
73
- if ( appMenu != nil )
74
- {
75
- expandCollapseStatusBar. menu = appMenu //set the menu
76
-
77
- let p = NSPoint ( x: 0 ,
78
- y: ( expandCollapseStatusBar. statusBar? . thickness) !)
79
- self . appMenu!. popUp ( positioning: self . appMenu!. item ( at: 0 ) , at: p , in: btnDot)
80
-
81
- }
82
- }
83
-
84
- @objc func expandCollapseIfNeeded( ) {
61
+ @objc func expandCollapseIfNeeded( _ sender: NSStatusBarButton ) {
85
62
if ( isValidPosition ( ) )
86
63
{
87
64
if isToggle == false {
0 commit comments