Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSStatusItem/StatusItem easy
Required plugins for this example: MBS MacCocoa Plugin, MBS MacBase Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSStatusItem/StatusItem easy
This example is the version from Sun, 17th Mar 2012.
Project "StatusItem easy.xojo_binary_project"
Class Window1 Inherits Window
EventHandler Sub Open() e = new NSStatusItemMBS call e.CreateMenu(-1) e.Title = "Test" e.HighlightMode=true // clickable m=new NSMenuMBS dim a as new MyCocoaMenuItemMBS a.CreateMenuItem "Some 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 "Next menu entry" c.Enabled=true c.Tag=2 c.state=1 items.Append c m.AddItem c dim d as new MyCocoaMenuItemMBS d.CreateMenuItem "Last menu entry" d.Enabled=false d.tag=3 items.Append d m.AddItem d e.Menu=m End EventHandler
Property Protected e As NSStatusItemMBS
Property Protected items(0) As NSMenuitemMBS
Property m As NSMenuMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class MyCocoaMenuItemMBS Inherits NSMenuItemMBS
EventHandler Sub Action() MsgBox "You chose menu item number "+str(tag) End EventHandler
End Class
Class App Inherits Application
EventHandler Sub Open() if TargetMachO=false then MsgBox "This example needs a MachO target running on Mac OS X." quit end if End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

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

The biggest plugin in space...

MBS Xojo Plugins