Platforms to show: All Mac Windows Linux Cross-Platform
/MacControls/Popover/Popover detachableWindowForPopover example
Required plugins for this example: MBS MacBase Plugin, MBS MacControls Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/Popover/Popover detachableWindowForPopover example
This example is the version from Tue, 18th Jul 2022.
Project "Popover detachableWindowForPopover example.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action()
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
if pw<>nil then
if pw.detachableWindow <> nil then
// detached
pw = nil
vc = nil
cw = nil
else
// close old
pw.performClose
cw = nil
pw = nil
vc = nil
end if
end if
// we use a PopoverWindow instance here just to get the view from there.
cw = new PopoverWindow
vc = New NSViewControllerMBS
vc.view = cw.ContainerControl11.NSViewMBS
pw = new MyNSPopoverMBS
pw.c = cw.ContainerControl11
pw.animates = true
pw.contentViewController = vc
pw.behavior = pw.NSPopoverBehaviorSemitransient
'pw.appearance = pw.NSPopoverAppearanceHUD
dim v as NSViewMBS = me.NSViewMBS
dim r as NSRectMBS = v.bounds
pw.showRelativeToRect(r, v, pw.MaxXEdge)
End EventHandler
End Control
Property cw As PopoverWindow
Property pw As MyNSPopoverMBS
Property vc As NSViewControllerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyNSPopoverMBS Inherits NSPopoverMBS
EventHandler Function detachableWindowForPopover() As NSWindowMBS
System.DebugLog CurrentMethodName
// we create another copy of the PopoverWindow with same text to detach
dim w as new PopoverWindow
if c <> nil then
w.ContainerControl11.TextField1.Text = c.TextField1.Text
end if
detachableWindow = w
Return w.NSWindowMBS
End EventHandler
EventHandler Sub popoverDidClose(notification as NSNotificationMBS)
System.DebugLog CurrentMethodName
End EventHandler
EventHandler Sub popoverDidDetach()
System.DebugLog CurrentMethodName
End EventHandler
EventHandler Sub popoverDidShow(notification as NSNotificationMBS)
System.DebugLog CurrentMethodName
End EventHandler
EventHandler Function popoverShouldClose() As boolean
System.DebugLog CurrentMethodName
Return True
End EventHandler
EventHandler Function popoverShouldDetach() As boolean
System.DebugLog CurrentMethodName
Return True
End EventHandler
EventHandler Sub popoverWillClose(notification as NSNotificationMBS)
System.DebugLog CurrentMethodName
End EventHandler
EventHandler Sub popoverWillShow(notification as NSNotificationMBS)
System.DebugLog CurrentMethodName
End EventHandler
Property c As ContainerControl1
Property detachableWindow As window
End Class
Class PopoverWindow Inherits Window
Control ContainerControl11 Inherits ContainerControl1
ControlInstance ContainerControl11 Inherits ContainerControl1
End Control
End Class
Class ContainerControl1 Inherits ContainerControl
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Rectangle1 Inherits Rectangle
ControlInstance Rectangle1 Inherits Rectangle
End Control
Control Oval1 Inherits Oval
ControlInstance Oval1 Inherits Oval
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
End Class
End Project
See also:
The items on this page are in the following plugins: MBS MacControls Plugin.