Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSStatusItem/Statusitem Counter
Required plugins for this example: MBS MacBase Plugin, MBS MacCF 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/NSStatusItem/Statusitem Counter
This example is the version from Sun, 17th Mar 2012.
Project "Statusitem Counter.rbp"
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 App Inherits Application
EventHandler Sub Open() dim f as FolderItem if TargetMachO=false then MsgBox "This example needs a MachO target running on Mac OS X." quit end if s=new NSStatusItemMBS if not s.Available then MsgBox "NSStatusItem not available." quit end if CountItem= new NSMenuItemMBS CountItem.CreateMenuItem "Counting..." CountItem.Enabled = true m = new NSMenuMBS m.addItem CountItem call s.CreateMenu s.HighlightMode=false s.Title="Click me" s.HighlightMode=true s.menu = m c=new clock c.Period=1000 c.mode=2 End EventHandler
Sub update() count = count + 1 CountItem.Title= str(count) // for console: System.DebugLog str(count) End Sub
Property CountItem As NSMenuItemMBS
Property c As clock
Property count As Integer
Property last As string
Property m As NSMenuMBS
Property s As NSStatusItemMBS
End Class
Class Clock Inherits CarbonEventsTimerMBS
EventHandler Sub Action() app.update End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

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

MBS Xojo Plugins