StatusItem OSX

Hi all :slight_smile:

im trying to get an desktop app with a status item…so i tried macoslib, but there are about 100 errors i put the folder macoslib on my project. And this lib is so big i dont want so much crap in my app.

is there an lightweight and good way to handle a status item?

did you try MBS Plugin?
We have a couple of example projects coming with plugin.

here is an Example, replace TextAreaIcon with your icon
and replace in Window1.open

Cocoa.StatusItem self, TextAreaIcon, nil , ""

TextAreaIcon with the name of your icon (and “” with a Text if you need )

The MBS solution truly is the most lightweight solution for this.

You could also sign on to and vote for <https://xojo.com/issue/1792>

[quote=182823:@Axel Schneider]here is an Example, replace TextAreaIcon with your icon
and replace in Window1.open

Cocoa.StatusItem self, TextAreaIcon, nil , ""

TextAreaIcon with the name of your icon (and “” with a Text if you need )[/quote]

Just what is supposed to happen with that example?
I downloaded it, ran it … and got a window with nothing special visible

[quote=182895:@Dave S]Just what is supposed to happen with that example?
I downloaded it, ran it … and got a window with nothing special visible[/quote]

no StatusItem ?

nope… a standard OSX window… named “UNTITLED”
no icons…

and I added a breakpoint just to be sure it was actually running, and it was

OSX 10.9.5, XOJO 2015r2

The window is just there and superfluous. Check your status bar - that’s where the StatusItem appears.

OH! I misunderstood… I thought it was supposed to appear right next to “untitled” in the window…

Yup… it works :slight_smile:

Now is there a way to get it to react to a click?

[quote=182792:@Christian Schmitz]did you try MBS Plugin?
We have a couple of example projects coming with plugin.[/quote]

Oh no? Where is this class hiding? Is there an easy example to check it out?

http://www.mbsplugins.com/NSStatusItem.shtml

Nice, i will try this :slight_smile:

is this inside the cocoa plugin i already bought :?

should be. Also in the download you got should be a couple of example projects.

i’ve tried it, seems to be a good solution, but i dont understand how can i use a png as icon for example.

And the Example Video seems to be old, cause there is no menu.createMenu in here o.O

Of course the video is not from yesterday.

CreateMenu call was removed as it’s not necessary any longer.

you can assign an image and NSImageMBS class has various ways to be created. From a Xojo picture, from a file, from data in memory. Just check the documentation.

hm when i try to use a picture like this:

statusitem.image = picturename

it fails cause he want a NSImageMBS

statusitem.image = new NSImageMBS(picturename)

Danke :slight_smile: nach einem Kaffee hatte ich das dann auch schon selber verstanden :smiley:

Was mir allerdings noch nicht klar ist, die MenĂĽpunkte sind deaktiviert, also man kann sie nicht klicken. Im Beispiel wurde einer mit dem state aktiviert, das scheint ihn aber nicht mehr sonderliche zu interessieren.

  statusitem = New NSStatusItemMBS
  dim statusimg as new NSImageMBS(synoSync_icon_16)
  
  if statusitem.CreateMenu then
    
    statusitem.image = statusimg
    statusitem.HighlightMode = true
    
    menu = new NSMenuMBS
    
    dim item as new NSMenuItemMBS
    
    item.CreateMenuItem
    item.Title = "#options"
    item.Enabled = true
    item.state = 1
    menu.addItem item
    items.Append item
    
    item = New NSMenuItemMBS
    item.CreateMenuItem
    item.title = "#quit"
    menu.addItem item
    items.Append item
    
    statusitem.menu = menu
    
  else
    
    MsgBox "This APP requires Mac OSX 10.3 or newer!"
    
  end if

Hab es raus :slight_smile:

enabled = true gesetzt?