Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSStatusItem/Statusitem with textfield in menubar
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin, MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSStatusItem/Statusitem with textfield in menubar
This example is the version from Sun, 17th Mar 2012.
Project "Statusitem with textfield in menubar.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"
MenuItem AppleAboutthisapplication = "About this application..."
End MenuBar
Class App Inherits Application
EventHandler Sub Close() if s<>nil then s.Close DelayMBS 0.2 // wait for events to flush s=nil end if End EventHandler
EventHandler Sub Open() myview = new NSViewMBS(0,0,150,20) mytext = new MyNSTextFieldMBS(20, 0, 110, 20) mytext.StringValue = "He" myview.addSubview mytext s=new NSStatusItemMBS // Create statusitem call s.CreateMenu s.HighlightMode=true s.Title="Click me" // create a menu to attach to the statusitem m=new NSMenuMBS // Create menu items VisitWebsiteMenu=new MyCocoamenuitem VisitWebsiteMenu.CreateMenuItem "Visit website" VisitWebsiteMenu.ID=2 m.AddItem VisitWebsiteMenu dim d as new NSMenuItemMBS d.CreateSeparator m.AddItem d DisplayMenu=new MyCocoamenuitem DisplayMenu.CreateMenuItem "" DisplayMenu.view = myview DisplayMenu.id=10 m.AddItem DisplayMenu d=new NSMenuItemMBS d.CreateSeparator m.AddItem d QuitMenu=new MyCocoamenuitem QuitMenu.CreateMenuItem "Quit" QuitMenu.ID=1 m.AddItem QuitMenu // attach menu s.Menu=m End EventHandler
EventHandler Function UnhandledException(error As RuntimeException) As Boolean quit Return true End EventHandler
Property Private DisplayMenu As myCocoamenuitem
Property QuitMenu As MyCocoamenuitem
Property UpdateMenu As mycocoamenuitem
Property VisitWebsiteMenu As mycocoamenuitem
Property Protected m As NSmenumBS
Property mylabel As NSTextViewMBS
Property mytext As MyNSTextFieldMBS
Property myview As NSViewMBS
Property Protected s As NSStatusItemMBS
End Class
Class MyCocoamenuitem Inherits NSMenuItemMBS
EventHandler Sub Action() Select case id case 1 quit case 2 ShowURL "http://www.monkeybreadsoftware.de" end Select End EventHandler
Property ID As integer
End Class
Class MyNSTextFieldMBS Inherits NSTextFieldMBS
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