Platforms to show: All Mac Windows Linux Cross-Platform
/MacCocoa/NSWindow transparent
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacControls Plugin, MBS MacCocoa Plugin
Last modified Sun, 17th Mar 2012.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /MacCocoa/NSWindow transparent
Download this example: NSWindow transparent.zip
Project "NSWindow transparent.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
// get a picture with mask
dim p as Picture = LogoMBS(500)
dim g as Graphics = p.mask.Graphics
g.ForeColor = &cFFFFFF
g.FillRect 0, 0, 500, 500
g.ForeColor = &c000000
g.FillOval 0, 0, 500, 500
// create window
dim stylemask as integer = 0
n = new NSWindowMBS(100, Screen(0).Height-600, 500, 500, stylemask)
n.hasShadow = true
n.isOpaque = false
c = new MyView(0, 0, 500, 500)
c.pic = new NSImageMBS(p,p.mask)
n.contentView.addSubview c
n.show
End EventHandler
Property c As MyView
Property n As NSWindowMBS
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 MyView Inherits CustomNSViewMBS
EventHandler Sub DrawRect(g as NSGraphicsMBS, left as double, top as double, width as double, height as double)
g.setColor NSColorMBS.clearColor
g.fillRect(0,0,500,500, g.NSCompositeCopy)
g.drawatpoint pic, 0, 0, 0, 0, 500, 500, g.NSCompositeCopy, 1.0
End EventHandler
EventHandler Function acceptsFirstMouse(e as NSEventMBS) As boolean
Return true
End EventHandler
EventHandler Function acceptsFirstResponder() As boolean
Return true
End EventHandler
EventHandler Function isOpaque() As boolean
Return false
End EventHandler
Property pic As NSImageMBS
End Class
End Project
See also:
Download this example: NSWindow transparent.zip
The items on this page are in the following plugins: MBS MacCocoa Plugin.