Platforms to show: All Mac Windows Linux Cross-Platform

/MacBase/Cocoa Menu Modification
Function:
Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacBase/Cocoa Menu Modification
This example is the version from Fri, 12th Jul 2012.
Project "Cocoa Menu Modification.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub EnableMenuItems() Ablagetest.Enable End EventHandler
EventHandler Sub Open() o = new MyMenuObserver dim c as NSNotificationCenterMBS = NSNotificationCenterMBS.defaultCenter c.addObserver o, NSMenuMBS.NSMenuDidAddItemNotification // make big image dim p as Picture = LogoMBS(32) dim n as new NSImageMBS(p) // make it smaller than pixels allow. Maybe helps for retina? n.setSize 16,16 img = n End EventHandler
Property img As NSImageMBS
Property o As MyMenuObserver
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() dim m as NSMenuMBS = NSApplicationMBS.sharedApplication.mainMenu 'MsgBox m.title dim m2 as NSMenuItemMBS = m.Item(1) 'MsgBox m2.title dim m3 as NSMenuMBS = m2.submenu 'MsgBox m3.title 'MsgBox str(m3.numberOfItems) dim m4 as NSMenuItemMBS = m3.Item(0) m4.Title = "hello" 'MsgBox m4.title 'm4.image= nil End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem Ablagetest = "test"
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 MyMenuObserver Inherits NSNotificationObserverMBS
EventHandler Sub GotNotification(notification as NSNotificationMBS) dim u as Dictionary = notification.userInfo dim m as NSMenuMBS = notification.objectVariant dim index as integer = u.Lookup("NSMenuItemIndex", -1) if index>=0 then dim n as NSMenuItemMBS = m.Item(index) System.DebugLog n.title if n.title = "test" then n.image = app.img end if end if End EventHandler
End Class
End Project

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


💬 Ask a question or report a problem
The biggest plugin in space...