NSStatusItem error?

Howdy Doody.

In a module I have a property called item1 (As NSStatusItem), and a method called ShowStatusItem, which creates an NSStatusItem (see the code below):

[code] // CREATE AN NSSTATUSITEM IN THE OS X MENUBAR
dim bar as NSStatusBar = NSStatusBar.SystemStatusBar
item1 = bar.CreateStatusItem(NSStatusBar.NSVariableStatusItemLength, AddressOf StatusItemHandler)
item1.highlightMode = true
item1.Image = NSStatusItemImage
item1.AlternateImage = NSStatusItemImage

// APPEND MENU ENTRIES
dim mmenu as new NSMenu
call mmenu.Append(“Open myApp”)
call mmenu.Append(“About”)
call mmenu.Append(“Quit”)

// DISPLAY THE MENU
item1.menu = mmenu[/code]

I call the method like this from the app.open event:

ShowStatusItem()

However, when I try to build I get the following error:

When I run the code from the app.open event - it all world perfectly, but when I put the property and method into a module - I get the error.

(I decided to put the method and property into a module, because I need to change the NSStatusItem image elsewhere in my app - when a certain window opens).

Could someone please help me, as to how / where I put my method and property in order to create the NSStatusItem, and also to allow me to update the image at a later date.

Thank you all in advance.

The problem is you do not have a method called StatusItemHandler (hence the error of it not existing). You will need to add the method StatusItemHandler to the module as well, or if you have already added it to the app then preface the method name with “App.”. StatusItemHandler will be the method which is called when a menu item is chosen from the NSStatusItem drop-down menu. Off the top of my head I think the method signature will need to be “StatusItemHandler(hitItem as NSMenuItem)” but I am not positive.

Duhhhhh - Thanks Jason.