Platforms to show: All Mac Windows Linux Cross-Platform

/MacBase/Menus/MacSonomaMenu


You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacBase/Menus/MacSonomaMenu

This example is the version from Sun, 7th Oct 2023.

Project "MacSonomaMenu.xojo_binary_project"
Class App Inherits DesktopApplication
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits DesktopWindow
EventHandler Sub MenuBarSelected() HelloMenu.Enabled = true End EventHandler
EventHandler Sub Opening() dim m as NSMenuItemMBS = NSMenuItemMBS.MenuItem(EditMenu) m.submenu.addItem NSMenuItemMBS.separatorItem // add the header dim h as NSMenuItemMBS = NSMenuItemMBS.sectionHeaderWithTitle("Section Header") h.Enabled = true m.submenu.addItem h self.SectionHeader = h // and the new entry with our MyNSMenuItemMBS class to handle validate and action. dim n as new MyNSMenuItemMBS("Hello") n.Enabled = true m.submenu.addItem n self.HelloMenu = n // keep references // define the colors and titles and create palette menu dim colors() as NSColorMBS colors.Append NSColorMBS.whiteColor colors.Append NSColorMBS.redColor colors.Append NSColorMBS.blueColor dim titles() as string = array("White", "Red", "Blue") paletteMenu = NSMenuMBS.paletteMenuWithColors(Colors, titles) AddHandler paletteMenu.PaletteSelectionChange, WeakAddressOf PaletteSelectionChange // the palette is hosted by an unnamed menu item dim p as new MyNSMenuItemMBS("") p.Enabled = true p.submenu = paletteMenu m.submenu.addItem p self.paletteMenuItem = p End EventHandler
Sub PaletteSelectionChange(m as NSMenuMBS) // we got a color selected dim selectedItems() as NSMenuItemMBS = m.selectedItems dim Titles() as string for each item as NSMenuItemMBS in selectedItems Titles.append item.Title next MessageBox Join(titles, " and ")+" selected" End Sub
Property HelloMenu As NSMenuItemMBS
Property PaletteMenu As NSMenuMBS
Property SectionHeader As NSMenuItemMBS
Property paletteMenuItem As NSMenuItemMBS
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"
MenuItem HelpMenu = "&Help"
End MenuBar
Class MyNSMenuItemMBS Inherits NSMenuItemMBS
EventHandler Sub Action() // a menu item was selected MessageBox me.Title+" clicked" End EventHandler
EventHandler Function validateMenuItem(menuItem as NSMenuItemMBS) As boolean // return true to enable menu item Return true End EventHandler
End Class
End Project

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


The biggest plugin in space...