Platforms to show: All Mac Windows Linux Cross-Platform
/MacControls/NSButton Control Array
Required plugins for this example: MBS MacFrameworks Plugin, 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: /MacControls/NSButton Control Array
This example is the version from Sun, 17th Mar 2012.
Project "NSButton Control Array.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control CoCo Inherits CocoaControlMBS
ControlInstance CoCo(0) Inherits CocoaControlMBS
ControlInstance CoCo(1) Inherits CocoaControlMBS
ControlInstance CoCo(2) Inherits CocoaControlMBS
EventHandler Function GetView(index as Integer) As NSViewMBS
// Create our button
dim n as new MyNSButtonMBS(0,0,100,20)
n.index = index
n.setButtonType n.NSToggleButton
n.bezelStyle = n.NSTexturedRoundedBezelStyle
n.Title = "Off"
n.alternateTitle = "On"
Return n
End EventHandler
End Control
EventHandler Sub Open()
// now we put the buttons into an array
redim button(-1)
for i as integer = 0 to 2
Button.Append MyNSButtonMBS(coco(i).View)
next
// and pass the button arrays to all buttons
for each b as MyNSButtonMBS in Button
b.buttons = Button
next
End EventHandler
Property Button() As MyNSButtonMBS
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 MyNSButtonMBS Inherits NSButtonMBS
EventHandler Sub Action()
// set state to off from other buttons
for each b as MyNSButtonMBS in buttons
if b<>self then
b.state = 0
end if
next
End EventHandler
Property buttons() As MyNSButtonMBS
Property index As Integer
End Class
End Project
See also:
The items on this page are in the following plugins: MBS MacControls Plugin.