Platforms to show: All Mac Windows Linux Cross-Platform

/MacControls/Toolbar/Toolbar customized


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

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

This example is the version from Mon, 14th Sep 2014.

Project "Toolbar customized.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open() t = new MyNSToolbarMBS dim w as NSWindowMBS = self.NSWindowMBS w.toolbar = t w.showsToolbarButton = true t.visible = true End EventHandler
Property t As MyNSToolbarMBS
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 MyNSToolbarMBS Inherits CustomNSToolbarMBS
EventHandler Function itemForItemIdentifier(identifier as string, willBeInsertedIntoToolbar as boolean) As NSToolbarItemMBS System.DebugLog CurrentMethodName+" "+str(willBeInsertedIntoToolbar) Select case identifier case "info" dim InfoItem as new MyNSToolbarItemMBS("info") InfoItem.label = "Info" dim logo as Picture = LogoMBS(500) dim n as new NSImageMBS(logo) InfoItem.image = n myItems.Append InfoItem return InfoItem case "test" dim TestItem as new MyNSToolbarItemMBS("test") TestItem.label = "Test" myItems.Append TestItem Return TestItem case "other" dim OtherItem as new MyNSToolbarItemMBS("other") OtherItem.label = "Other" myItems.Append OtherItem Return OtherItem case "sep" dim SepItem as new NSToolbarItemMBS(NSToolbarItemMBS.NSToolbarSeparatorItemIdentifier) myItems.Append SepItem Return SepItem end Select End EventHandler
EventHandler Function toolbarAllowedItemIdentifiers() As string() System.DebugLog CurrentMethodName Return array("info", "test", "sep", "other") End EventHandler
EventHandler Function toolbarDefaultItemIdentifiers() As string() System.DebugLog CurrentMethodName Return array("info", "test", "sep", "other") End EventHandler
EventHandler Sub toolbarDidRemoveItem(item as NSToolbarItemMBS, notification as NSNotificationMBS) System.DebugLog CurrentMethodName if item<>nil then System.DebugLog "item: "+item.label end if End EventHandler
EventHandler Function toolbarSelectableItemIdentifiers() As string() System.DebugLog CurrentMethodName Return array("info", "test", "sep", "other") End EventHandler
EventHandler Sub toolbarWillAddItem(item as NSToolbarItemMBS, notification as NSNotificationMBS) System.DebugLog CurrentMethodName if item<>nil then System.DebugLog "item: "+item.label end if End EventHandler
Sub Constructor() System.DebugLog CurrentMethodName Super.Constructor("MyToolbar") End Sub
Property myItems() As Variant
End Class
Class MyNSToolbarItemMBS Inherits CustomNSToolbarItemMBS
EventHandler Sub Action() System.DebugLog CurrentMethodName MsgBox "Action in "+me.label End EventHandler
EventHandler Function validate() As boolean Return true End EventHandler
End Class
End Project

See also:

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


The biggest plugin in space...