Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSStatusItem/Statusitem with PopOver using Container
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacControls Plugin, MBS Main Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSStatusItem/Statusitem with PopOver using Container
This example is the version from Mon, 10th Jan 2016.
Project "Statusitem with PopOver using Container.rbp"
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu7 = ""
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu6 = ""
MenuItem AppleAboutthisapplication = "About this application..."
MenuItem UntitledMenu5 = ""
MenuItem UntitledMenu4 = ""
End MenuBar
Class App Inherits Application
EventHandler Sub Close() if s<>nil then s.Close DelayMBS 0.2 // wait for events to flush s=nil end if End EventHandler
EventHandler Sub Open() if TargetCocoa = false then MsgBox "This example is only for Cocoa target." end if if NSPopoverMBS.available = false then MsgBox "Please update to Mac OS X 10.7 (Lion)" Return end if s=new MyNSStatusItemMBS // Create statusitem call s.CreateMenu s.HighlightMode=true s.Title="Click me" s.conMain = Window1.ContainerControl11 End EventHandler
EventHandler Function UnhandledException(error As RuntimeException) As Boolean quit Return true End EventHandler
Property Protected m As NSmenumBS
Property Protected s As MyNSStatusItemMBS
End Class
Class MyNSStatusItemMBS Inherits NSStatusItemMBS
EventHandler Sub Action() if pvrTask <> nil then pvrTask.performClose pvrTask = nil vcTask = nil else vcTask = new NSViewControllerMBS vcTask.view = conMain.NSViewMBS pvrTask = new NSPopoverMBS pvrTask.animates = true pvrTask.contentViewController = vcTask //pvrTask.behavior = pvrTask.NSPopoverBehaviorSemitransient pvrTask.appearance = pvrTask.NSPopoverAppearanceHUD dim f as NSRectMBS = self.window.frame dim r as NSRectMBS = NSMakeRectMBS(0, 0, f.Width, f.Height) dim v as NSViewMBS = self.window.contentView pvrTask.showRelativeToRect(r, v, pvrTask.MaxYEdge) end if End EventHandler
Property conMain As ContainerControl
Property pvrTask As NSPopoverMBS
Property txtTask As NSTextFieldMBS
Property vcTask As NSViewControllerMBS
End Class
Class MyNSPopoverMBS Inherits NSPopoverMBS
End Class
Class Window1 Inherits Window
Control ContainerControl11 Inherits ContainerControl1
ControlInstance ContainerControl11 Inherits ContainerControl1
End Control
End Class
Class ContainerControl1 Inherits ContainerControl
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() msgbox textarea1.text End EventHandler
End Control
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCocoa Plugin.

MBS Xojo Chart Plugins