Example: /MacCocoa/Dock Menu/Dock menu with ApplicationDelegate

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Dock Menu/Dock menu with ApplicationDelegate


Required plugins for this example: MBS MacBase 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: /MacCocoa/Dock Menu/Dock menu with ApplicationDelegate

This example is the version from Wed, 2nd Sep 2014.

Project "Dock menu with ApplicationDelegate.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() System.DebugLog CurrentMethodName End EventHandler
Sub Constructor() System.DebugLog CurrentMethodName if not TargetCocoa then MsgBox "Please run this example on Cocoa target." end if m = new MyApplicationDelegate End Sub
Property Protected m As MyApplicationDelegate
End Class
Class Window1 Inherits Window
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 MyApplicationDelegate Inherits NSApplicationDelegateMBS
EventHandler Function applicationDockMenu() As NSMenuMBS redim items(-1) // clear last menuitems // we do keep menu item objects in an array, so the Real Studio object with the event handler stays alive. m=new NSMenuMBS dim a as new MyCocoaMenuItemMBS a.CreateMenuItem "Top menu entry" a.Enabled=true a.Tag=1 items.Append a // so RB doesn't free the object. m.AddItem a dim b as new MyCocoaMenuItemMBS b.CreateSeparator items.Append b m.AddItem b dim c as new MyCocoaMenuItemMBS c.CreateMenuItem "Middle menu entry" c.Enabled=true c.Tag=2 c.state=1 items.Append c m.AddItem c dim d as new MyCocoaMenuItemMBS d.CreateMenuItem "Bottom menu entry" d.Enabled=false d.tag=3 items.Append d m.AddItem d dim e as new MyCocoaMenuItemMBS e.CreateMenuItem "Greetings from Real Studio" e.Enabled=true e.tag=3 items.Append e m.AddItem e return m End EventHandler
Property Protected items() As NSMenuItemMBS
Property Protected m As NSMenuMBS
End Class
Class MyCocoaMenuItemMBS Inherits NSMenuItemMBS
EventHandler Sub Action() MsgBox "You chose menu item number "+str(tag) End EventHandler
End Class
End Project

See also:

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


💬 Ask a question or report a problem