Platforms to show: All Mac Windows Linux Cross-Platform

/MacExtras/MAAttachedWindow/MAAttachedWindow Demo


Required plugins for this example: MBS MacBase Plugin, MBS MacExtras Plugin, MBS MacCocoa Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacExtras/MAAttachedWindow/MAAttachedWindow Demo

This example is the version from Mon, 22th Nov 2015.

Project "MAAttachedWindow Demo.xojo_binary_project"
Class App Inherits Application
End Class
Class Window1 Inherits Window
Control LogoCanvas Inherits Canvas
ControlInstance LogoCanvas Inherits Canvas
EventHandler Sub MouseExit() Call CloseWindow() End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer) Call ShowWindow() End EventHandler
EventHandler Sub Open() Me.Backdrop = LogoMBS(256) End EventHandler
End Control
EventHandler Sub Close() Quit() End EventHandler
Function CloseWindow() As Boolean If not (MAAttachedWindow = Nil) Then Self.NSWindowMBS.removeChildWindow(MAAttachedWindow) Dim NSWindowAnimator as NSWindowMBS = MAAttachedWindow.animator() If (NSWindowAnimator = Nil) Then MAAttachedWindow.Close() Else NSWindowAnimator.alphaValue = 0.0 End If MAAttachedWindow = Nil End If Return True Exception Return False End Function
Function ShowWindow() As Boolean If (MAAttachedWindow = Nil) Then Dim NSWindow as NSWindowMBS = Self.NSWindowMBS Dim MAPosition as Integer = MAAttachedWindowMBS.MAPositionBottom Dim MADistance as Double = 10.0 Dim NSPoint as New NSPointMBS(Self.Width / 2, 10) Dim NSTextField as New NSTextFieldMBS(10, 0, 200, 92) NSTextField.StringValue = "This is the logo of awesome MonkeyBread Software." + EndOfLine + EndOfLine + "Many thanks to Matt Gemmell for creating MAAttachedWindow." NSTextField.Editable = False NSTextField.textColor = NSColorMBS.whiteColor() NSTextField.backgroundColor = NSColorMBS.blackColor() NSTextField.Bordered = False Dim NSView as New NSViewMBS(0, 0, 220, 102) NSView.addSubview(NSTextField) MAAttachedWindow = MAAttachedWindowMBS.attachedWindow(NSView, NSPoint, NSWindow, MAPosition, MADistance) MAAttachedWindow.borderColor = NSColorMBS.whiteColor MAAttachedWindow.backgroundColor = NSColorMBS.blackColor MAAttachedWindow.viewMargin = 4 MAAttachedWindow.borderWidth = 3 MAAttachedWindow.cornerRadius = 8 MAAttachedWindow.drawsRoundCornerBesideArrow = True MAAttachedWindow.arrowBaseWidth = 20 MAAttachedWindow.arrowHeight = 15 MAAttachedWindow.hasArrow = True MAAttachedWindow.alphaValue = 0.0 NSWindow.addChildWindow(MAAttachedWindow, NSWindowMBS.NSWindowAbove) Dim NSWindowAnimator as NSWindowMBS = MAAttachedWindow.animator() If (NSWindowAnimator = Nil) Then MAAttachedWindow.alphaValue = 0.9 Else NSWindowAnimator.alphaValue = 0.9 End If MAAttachedWindow.Show() Self.Show() //a 'hack' to not set the MAAttachedWindow to the front End If Return True Exception Return False End Function
Note "About"
This example was created by Joris Vervuurt
Property MAAttachedWindow As MAAttachedWindowMBS
End Class
MenuBar MenuBar1
End MenuBar
End Project

See also:

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


The biggest plugin in space...