Four OS X questions

Hi,
Instead of creating 4 separate posts, I have combined my questions into this single post.
Hopefully, people can answer each question as and when they get the chance.

  1. Is it possible to put code into a button’s action event, which when clicked, will add my app to the list of autostart upon login?
    If, so - could someone please point me in the right direction.

  2. Could someone also point me to where I get information regarding putting an icon into the OS X menubar (I believe it is called a menubarlet)?

  3. Regarding MacOSLib - is it simply a list of declares and code which provides features not directly available in Xojo - or - does it also contain controls / classes etc? Also, if I use MacOSLib in my project - will it cause my compiled app to create a myApp.Libs folder? At the moment, my compiled app does not create a libs folder as it is not required.

  4. I have 4 windows (all set to use MenuBar1). However, Only my main window and one other window (movable modal, which is initiated from the menubar itself) actually display the menubar. The other 2 windows (also movable modal) cause the menubar to disappear when they open? Any ideas what could be the cause?

Thank you all in advance for any help you can provide.

#3) MacOsLib will only compile (and thus increase the size of your app) for any portions of it that you actually use. I just wish the level of documentation was adequate to help understand all the code there.

#4) If you have a window that causes the menubar to disappear, then you did not attach the menubar to it. Click on the window. Look at the inspector…very bottom “MENUS”… make sure it does NOT say “NONE”

  1. and 2) I believe there is such code in MacOSLib, but don’t know for sure.

  2. It’s a set of classes and functions to essentially “port” the the OS X toolbox into Xojo code. Instead of using declares to implement an NSDictionary, for example, you’d dim nsd as new NSDictionary and all the necessary declares are handled for you. You’d then use it like you would any other Xojo class.

Among the things that are implemented are controls like the search field.

Since MacOSLib is just a set of modules and classes, there is no Lib folder created.

  1. Are you setting MenuBarVisible to False somewhere?

#2) I think you mean a NSStatusItem. An example is in Examples -> Cocoa -> NSStatusItem if you run the project. If you want it to remain in the StatusBar after the user quits your application it will have to be a separate application.

Thank you so much guys.

I understand the MacOSLib answer - thank you.

Regarding the Menubar question - ALL of the windows have MenuBar1 set in the inspector, but only 2 of the four actually display it?? And I am not using MenuBarVisible=false anywhere. That is what I find so complexing :frowning:

Why does this forum always change the words I type !!!
I typed perplexing, and it displayed complexing :slight_smile:

Here is a screenshot of the inspector - showing that MenuBar1 is set:

That says MENUBAR1… the default is “MainMenuBar”
So did you create a 2nd menubar? are you sure it has items on it? (just grasping at straw here)
I assume you are seeing “SOMETHING”… if I delete items from a test menubar… I still see “MyApplication”

In the MBS Plugins we have NSStatusItemMBS class for the menu item.
And for auto launch on login, you can use the LSSharedFileListMBS class. (or LoginItemsMBS class for older Mac OS X versions)

Also we have a video for the NSStatusItem creation:
http://mbsplugins.com/NSStatusItem.shtml

Dave,
I deleted the original default MenuBar when I first started the project. I then later created MenuBar1, which is now the only MenuBar in my project, and all windows are set to display it. Yes - it has items in it because the other window which displays the MenuBar correctly can also be called from within MenuBar1 itself.

Example:
My main window displays MenuBar1.
From within MenuBar 1 I can open Window2 - which correctly displays the same MenuBar1.
Windows 3 and 4 are also set to display MenuBar1, but when they open - the MenuBar1 disappears???

There is no other MenuBar code in my entire project?

I have even duplicated MenuBar1 and renamed it MenuBar2, and then set the two troublesome windows to use that MenuBar - TO NO AVAIL - the same thing happens - no MenuBar is displayed.

Christian,
I already own all of your plugins so I will look into it.

Thanks.

I just experimented quickly. If you delete the MainMenuBar and later insert a new menubar, even if you rename it to MainMenuBar, it fails indeed to show the menu.

The solution I found is to copy MainMenuBar from a new project and paste it back into the crippled project. Then it shows in all the app. You will have to recreate the items but it will work. Lessons is : do not delete the default MainMenuBar :wink: (Why did you in the first place ? ? ?)

Never made an OS X app before so I was just experimenting. Then I decided to turn the project file into an app, thus having to recreate a new MenuBar :slight_smile:

WON’T DO THAT AGAIN :slight_smile:

SO I will:

  1. Start a new empty project

  2. Copy the default MainMenuBar into my messed up project file.

  3. Recreate all the menu handlers etc.

  4. Set MainMenuBar in all my windows again.

Thanks Michel - I will try that now.

That didn’t work either :frowning:
Is it safe to delete the File and Edit menus?

[quote=83226:@Richard Summers]That didn’t work either :frowning:
Is it safe to delete the File and Edit menus?[/quote]

In the window inspector, at the very bottom, in the Menus section set the menubar property to MenuBar1. Do that for every window.

You can delete and recreate all items in your menu with the menu editor. Just make sure that menu item names and your menu handlers names do match afterward.

I have already done that and it refuses to work.

I give up. Your code must be haunted by a gremlin :wink:

Maybe try to create another menu bar and set the window to it ? It does work here, but who knows ?

I have now given up :frowning:

I even deleted the menubar so there was NONE, then added a brand new one, but that still didn’t show when the other windows opened :frowning:

Changed the layout of my app so there are no other windows :slight_smile:

Thank you for trying to help.

I think the next step is to share your project so we can look directly.

I would love to, but I am involved in Security and therefore unfortunately cannot :frowning:

it’s ok though, as I have changed the layout so as to not need any other windows.
Thanks for the offer - much appreciated.

I do not know if this is the same problem for you but I had to solve a strange disappearance of a menubar recently. After a while I realised that the menubar was absent for one of the Application’s window. I tracked back the bug in older version of the application to see when it started to show-up and I found that it was a kind of corruption of a Menubar reference number. I think it actually happened when I was trying to create a Menulet.

To check if it is the same problem: you should save your application in version control format. Then open (for example using Texwrangler) the file corresponding to the windows that lost the Menubar.
You should see a parameter “Menubar = 0”. In my case, the problem was that it was something like a random number (something like “MenuBar = 2345467”). I just put it back to “Menubar = 0” and it solved the problem
Hope it will help.