Hi,
I need an example of how to create an OSX app that runs in the background with an icon menu in the top right menubar. So, just like the system tray in Windows. If the example includes the code needed to include the app in the login startup then I would be even more grateful :).
NB: Yes, I’ve searched the examples, documentation and this forum, but I couldn’t find it (maybe I didn’t look good enough …). I also try to avoid using plugins.
Thanks!
You’re either going to need MBS or declares, you’re looking at NSStatusItem.
To take it out of the dock you need to change the Info.plist to add a key to make it not show up in the dock, or more declares (the proper way to do it in 10.10 and up)
It’s not the simplest thing to do in Xojo. I recommend doing NSStatusItem only apps with Xcode.
[quote=285878:@Marc de Bruin]Hi,
I need an example of how to create an OSX app that runs in the background with an icon menu in the top right menubar. So, just like the system tray in Windows. If the example includes the code needed to include the app in the login startup then I would be even more grateful :).
NB: Yes, I’ve searched the examples, documentation and this forum, but I couldn’t find it (maybe I didn’t look good enough …). I also try to avoid using plugins.
Thanks![/quote]
First, you need a StatusItem : the little icon in the menu bar. This is not built in Xojo. There is an example in MacOSLib and MBS of course offers NSStatusItemMBS.
Then you need your app to run stealth without an icon in the dock. See https://forum.xojo.com/11024-how-to-start-app-with-no-window-and-without-icon-in-dock/0
Finally, you probably need your app to start with the system. I use Valdemar de Sousa’s VDSC. See https://forum.xojo.com/14457-launchagents-howto/1
The app will in fact be running, waiting for the user to click the StatusItem, but it won’t be visible in the dock. When the user clicks the StatusItem, then show a menu, a window, whatever.
2 Likes