Replies: 2 comments
-
Moved this question from issues to discussions. Googling I found this: https://stackoverflow.com/questions/14425129/how-to-create-a-status-bar-popover-view-menu That should tell you how to approach it. You can also refer to Apple documentation. If there are classes missing in macdriver, you can add them or use them dynamically. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I've actually just did that. I had to create my own type NSPopover struct {
objc.Object
}
const (
NSPopoverBehaviorApplicationDefined = 0
NSPopoverBehaviorTransient = 1
NSPopoverBehaviorSemitransient = 2
)
func NSPopover_Init() NSPopover {
return NSPopover{objc.Get("NSPopover").Alloc().Send("init")}
}
type NSViewController struct {
objc.Object
}
func NSViewController_Init() NSViewController {
return NSViewController{objc.Get("NSViewController").Alloc().Send("init")}
}
po := NSPopover_Init()
po.Send("setContentSize:", core.NSMakeSize(200, 200))
o.Send("setBehavior:", NSPopoverBehaviorApplicationDefined)
po.Send("setAnimates:", core.False)
// w is whatever NSView you want to use. In my case is a WKWebView subclass that I'm using as a delegate too.
po.Send("setDelegate:", w)
vc := NSViewController_Init()
vc.Send("setView:", w)
po.Send("setContentViewController:", vc)
obj := cocoa.NSStatusBar_System().StatusItemWithLength(cocoa.NSSquareStatusItemLength)
obj.Retain()
obj.SetAction(objc.Sel("popover:"))
set := false
cocoa.DefaultDelegateClass.AddMethod("popover:", func(_ objc.Object) {
if set {
po.Send("performClose:", po)
set = false
} else {
set = true
po.Send("showRelativeToRect:ofView:preferredEdge:", obj.Button().Bounds(), obj.Button(), 1)
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Beta Was this translation helpful? Give feedback.
All reactions