Platforms to show: All Mac Windows Linux Cross-Platform
/MacFrameworks/Cocoa Controls/Cocoa Controls
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: /MacFrameworks/Cocoa Controls/Cocoa Controls
This example is the version from Thu, 9th Oct 2013.
Project "Cocoa Controls.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control NSButtonControlMBS1 Inherits NSButtonControlMBS
ControlInstance NSButtonControlMBS1 Inherits NSButtonControlMBS
EventHandler Sub Action()
log CurrentMethodName
End EventHandler
EventHandler Sub Close()
log CurrentMethodName
End EventHandler
EventHandler Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
End EventHandler
EventHandler Function ContextualMenuAction(hitItem as MenuItem) As Boolean
End EventHandler
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean
log CurrentMethodName
End EventHandler
EventHandler Sub KeyUp(Key As String)
log CurrentMethodName
End EventHandler
EventHandler Sub MouseEnter()
End EventHandler
EventHandler Sub MouseExit()
End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer)
End EventHandler
EventHandler Function MouseWheel(X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean
End EventHandler
EventHandler Sub Open()
log CurrentMethodName
End EventHandler
End Control
Control NSPopUpButtonControlMBS1 Inherits NSPopUpButtonControlMBS
ControlInstance NSPopUpButtonControlMBS1 Inherits NSPopUpButtonControlMBS
EventHandler Sub Action()
dim p as NSPopUpButtonMBS = me.View
dim m as NSMenuItemMBS = p.selectedItem
if m<>nil then
log CurrentMethodName+": "+m.title
else
log CurrentMethodName+": no selection"
end if
End EventHandler
EventHandler Sub Close()
log CurrentMethodName
End EventHandler
EventHandler Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
End EventHandler
EventHandler Function ContextualMenuAction(hitItem as MenuItem) As Boolean
End EventHandler
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean
log CurrentMethodName
End EventHandler
EventHandler Sub KeyUp(Key As String)
log CurrentMethodName
End EventHandler
EventHandler Sub MouseEnter()
End EventHandler
EventHandler Sub MouseExit()
End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer)
End EventHandler
EventHandler Function MouseWheel(X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean
End EventHandler
EventHandler Sub Open()
log CurrentMethodName
dim p as NSPopUpButtonMBS = me.View
p.addItemWithTitle "Hello"
p.addItemWithTitle "World"
End EventHandler
End Control
Control NSSearchFieldControlMBS1 Inherits NSSearchFieldControlMBS
ControlInstance NSSearchFieldControlMBS1 Inherits NSSearchFieldControlMBS
EventHandler Sub Action()
log CurrentMethodName
End EventHandler
EventHandler Sub Close()
log CurrentMethodName
End EventHandler
EventHandler Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
End EventHandler
EventHandler Function ContextualMenuAction(hitItem as MenuItem) As Boolean
End EventHandler
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean
log CurrentMethodName
End EventHandler
EventHandler Sub KeyUp(Key As String)
log CurrentMethodName
End EventHandler
EventHandler Sub MouseEnter()
End EventHandler
EventHandler Sub MouseExit()
End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer)
End EventHandler
EventHandler Function MouseWheel(X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean
End EventHandler
EventHandler Sub Open()
log CurrentMethodName
End EventHandler
End Control
Control NSTextFieldControlMBS1 Inherits NSTextFieldControlMBS
ControlInstance NSTextFieldControlMBS1 Inherits NSTextFieldControlMBS
EventHandler Sub Action()
log CurrentMethodName
End EventHandler
EventHandler Sub Close()
log CurrentMethodName
End EventHandler
EventHandler Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
End EventHandler
EventHandler Function ContextualMenuAction(hitItem as MenuItem) As Boolean
End EventHandler
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean
log CurrentMethodName
End EventHandler
EventHandler Sub KeyUp(Key As String)
log CurrentMethodName
End EventHandler
EventHandler Sub MouseEnter()
End EventHandler
EventHandler Sub MouseExit()
End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer)
End EventHandler
EventHandler Function MouseWheel(X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean
End EventHandler
EventHandler Sub Open()
log CurrentMethodName
End EventHandler
End Control
Control NSTextViewControlMBS1 Inherits NSTextViewControlMBS
ControlInstance NSTextViewControlMBS1 Inherits NSTextViewControlMBS
EventHandler Sub Close()
log CurrentMethodName
End EventHandler
EventHandler Function ConstructContextualMenu(base as MenuItem, x as Integer, y as Integer) As Boolean
End EventHandler
EventHandler Function ContextualMenuAction(hitItem as MenuItem) As Boolean
End EventHandler
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean
End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer)
End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean
log CurrentMethodName
End EventHandler
EventHandler Sub KeyUp(Key As String)
log CurrentMethodName
End EventHandler
EventHandler Sub MouseEnter()
End EventHandler
EventHandler Sub MouseExit()
End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer)
log CurrentMethodName+ " "+str(x)+"/"+str(y)
End EventHandler
EventHandler Function MouseWheel(X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean
End EventHandler
EventHandler Sub Open()
log CurrentMethodName
dim t as NSTextViewMBS = me.View
t.isRichText = true
t.isEditable = true
t.GrammarCheckingEnabled = true
t.isSelectable = true
End EventHandler
EventHandler Function shouldChangeTextInRange(affectedCharRange as NSRangeMBS, replacementString as string) As boolean
log CurrentMethodName
Return true
End EventHandler
EventHandler Sub textDidBeginEditing()
log CurrentMethodName
End EventHandler
EventHandler Sub textDidChange()
log CurrentMethodName
End EventHandler
EventHandler Sub textDidEndEditing()
log CurrentMethodName
End EventHandler
EventHandler Function textShouldBeginEditing() As boolean
log CurrentMethodName
End EventHandler
EventHandler Function textShouldEndEditing() As boolean
log CurrentMethodName
End EventHandler
EventHandler Sub textViewDidChangeSelection()
log CurrentMethodName
End EventHandler
End Control
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control TextField1 Inherits TextField
ControlInstance TextField1 Inherits TextField
End Control
Sub log(s as string)
Listbox1.InsertRow 0,s
End Sub
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
See also:
- /MacFrameworks/Cocoa Controls/NSButton test
- /MacFrameworks/Cocoa Controls/NSComboBox Example
- /MacFrameworks/Cocoa Controls/NSProgressIndicator
- /MacFrameworks/Cocoa Controls/NSSearchfield with event
- /MacFrameworks/Cocoa Controls/SearchField with menu
- /MacFrameworks/Cocoa Controls/SecureTextField
- /MacFrameworks/Cocoa Controls/SliderView
- /MacFrameworks/Cocoa Controls/TableView with scrollbars
- /MacFrameworks/Cocoa Controls/TextView
- /MacFrameworks/Cocoa Controls/TextView with events
The items on this page are in the following plugins: MBS MacFrameworks Plugin.