Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/TableControl


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

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacControls/TableControl

This example is the version from Tue, 6th Mar 2017.

Project "TableControl.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control MyTableControl Inherits myNSTableControlMBS
ControlInstance MyTableControl Inherits myNSTableControlMBS
EventHandler Sub ColumnDidMove(notification as NSNotificationMBS, OldColumn as Integer, NewColumn as Integer) log "ColumnDidMove" log " OldColumn: "+str(oldColumn) log " NewColumn: "+str(newColumn) End EventHandler
EventHandler Sub ColumnDidResize(notification as NSNotificationMBS, TableColumn as NSTableColumnMBS, OldWidth as Double) log "ColumnDidResize" dim index as integer = 0 if c2 = TableColumn then index = 1 end if log " index: "+str(index) End EventHandler
EventHandler Sub Open() dim i as integer scrollview = me.ScrollView c1=new MyNSTableColumn("First") c1.Width=200 c2=new MyNSTableColumn("Second") c2.Width=200 me.c1=c1 me.c2=c2 for i=0 to 99 c1.data(i)=str(i) c2.data(i)=str(i*i) next n = me.View n.usesAlternatingRowBackgroundColors=true n.gridStyleMask=n.NSTableViewSolidHorizontalGridLineMask+n.NSTableViewSolidVerticalGridLineMask n.addTableColumn c1 n.addTableColumn c2 scrollview.hasHorizontalScroller = true scrollview.hasVerticalScroller = true scrollview.autohidesScrollers = true End EventHandler
EventHandler Sub SelectionDidChange(notification as NSNotificationMBS) log "SelectionDidChange" End EventHandler
EventHandler Sub SelectionIsChanging(notification as NSNotificationMBS) log "SelectionIsChanging" End EventHandler
End Control
Sub log(s as string) System.DebugLog s MainWindow.Listbox1.AddRow s End Sub
Property c1 As MyNSTableColumn
Property c2 As MyNSTableColumn
Property n As NSTableViewMBS
Property scrollview As nsscrollViewMBS
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 MyNSTableColumn Inherits nsTableColumnMBS
Property data(99) As variant
End Class
Class MyNSTableControlMBS Inherits NSTableControlMBS
EventHandler Function numberOfRowsInTableView() As Integer Return 100 End EventHandler
EventHandler Function objectValue(column as NSTableColumnMBS, row as Integer) As Variant if column=c1 then Return c1.data(row) elseif column=c2 then Return c2.data(row) end if End EventHandler
EventHandler Sub setObjectValue(value as Variant, column as NSTableColumnMBS, row as Integer) if column=c1 then c1.data(row)=value elseif column=c2 then c2.data(row)=value end if End EventHandler
Property c1 As mynsTablecolumn
Property c2 As mynsTablecolumn
End Class
End Project

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


The biggest plugin in space...