Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS MacBase Plugin, MBS MacControls 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: /MacCocoa/NSWindow HUD Test
This example is the version from Sun, 17th Mar 2012.
Project "NSWindow HUD Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
dim x as Double = 100
dim y as Double = screen(0).Height-100 // Cocoa has reversed y axis
dim w as Double = 250
dim h as Double = 300
dim styleMask as integer
dim BackingStoreType as integer = 2 // NSBackingStoreBuffered
styleMask = BitwiseOr(styleMask, NSWindowMBS.NSTitledWindowMask) // with title bar
styleMask = BitwiseOr(styleMask, NSWindowMBS.NSClosableWindowMask) // with close button
styleMask = BitwiseOr(styleMask, NSWindowMBS.NSMiniaturizableWindowMask) // with minimize button
'styleMask = BitwiseOr(styleMask, NSWindowMBS.NSResizableWindowMask) // with resize gadget
styleMask = BitwiseOr(styleMask, NSPanelMBS.NSHUDWindowMask) // make it HUD
styleMask = BitwiseOr(styleMask, NSPanelMBS.NSUtilityWindowMask) // and make it a palette
win = new NSPanelMBS(x,y,w,h, styleMask, BackingStoreType, true)
// add a few labels
dim label1 as new NSTextFieldMBS(120,270,100,20)
label1.Editable = false
label1.Bezeled = false
label1.Bordered = false
label1.drawsBackground = false
label1.textColor = NSColorMBS.whiteColor
labels.Append label1
win.contentView.addSubview label1
dim label2 as new NSTextFieldMBS(120,240,100,20)
label2.Editable = false
labels.Append label2
win.contentView.addSubview label2
// add a slider
slider = new MyNSSliderMBS(10, 270, 100, 20)
slider.maxValue = 100
slider.minValue = 0
slider.DoubleValue = 50
slider.label = label1
win.contentView.addSubview slider
// add popup
popup = new myNSPopupButtonMBS(10, 240, 100, 20)
popup.addItemWithTitle "Europe"
popup.addItemWithTitle "Asia"
popup.addItemWithTitle "America"
popup.addItemWithTitle "Africa"
popup.addItemWithTitle "Australia"
popup.label = label2
win.contentView.addSubview popup
// and show
win.show
End EventHandler
Property labels() As NSTextFieldMBS
Property popup As myNSPopupButtonMBS
Property slider As MyNSSliderMBS
Property win As NSWindowMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyNSSliderMBS Inherits NSSliderMBS
EventHandler Sub Action()
label.StringValue = str(me.intValue)
End EventHandler
Property label As NSTextFieldMBS
End Class
Class myNSPopupButtonMBS Inherits NSPopupButtonMBS
EventHandler Sub Action()
label.StringValue = me.selectedItem.Title
End EventHandler
Property label As NSTextFieldMBS
End Class
End Project
See also:
The items on this page are in the following plugins: MBS MacCocoa Plugin.