• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [NSapp mainMenu] returns nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [NSapp mainMenu] returns nil


  • Subject: Re: [NSapp mainMenu] returns nil
  • From: Christian Stieber <email@hidden>
  • Date: Tue, 04 Apr 2006 10:46:44 +0200

At 14:09 03.04.2006 +0200, I wrote:
At 18:26 30.03.2006 +0200, you wrote:

Do you ever call NSApplicationMain()?

No. I'm still not doing it, but when I looked at the "docs" for that function, I saw NSApplicationLoad() just above it, which seemed more appropiate. Currently I'm calling that just before +sharedApplication --- and what do you say, I get a main menu :-) Quit from there doesn't work, but I suspect that's because the Apple-Q shortcut is still in the other menu or something like that, but I'm a step ahead already :-) Looks MUCH better now...

Well, doesn't look too good anymore :-( I played around quite a bit, but I seem to have two choices:

a) the good ol' empty application menu. "Quit" from the
   dock works:

                  [NSApplication sharedApplication];
                  Delegate=[[TestDelegate alloc] init];
                  [NSApp setDelegate:Delegate];
                  NSApplicationLoad();
                  if (WTG_Framework_Preferences_Init())
                     ... init stuff ...
                     [NSApp run];


b) a normal application menu, with Hide working and Quit not working. In that case, "Quit" from the dock doesn't work either:

                  NSApplicationLoad();
                  [NSApplication sharedApplication];
                  Delegate=[[TestDelegate alloc] init];
                  [NSApp setDelegate:Delegate];
                  if (WTG_Framework_Preferences_Init())
                     ... init stuff ...
                     [NSApp run];

So it seems the placement of the Load is critical, but it's
still in the wrong place, as I can get it to create the menu,
but it's still not fully connected to the NSApp object.

The menu returned from [NSApp mainMenu] is nil in both
cases, so I still can't add new entries into there (which
isn't a problem if I can get the Quit to work, since the
only item that was requested is "About", which I can stick
into a separate Help menu without getting headaches).

I also tried to "wait" for the didFinishLaunching method
by setting having the delegate call [NSApp stop], and just
run [NSApp run] after the Load(). It did get the method,
but the stop was ignored, so nothing happened.

I also tried to move all my initialization into the
didFinishLaunching method on the delegate, but that caused
tons of problems. I tried various combinations of
NSApplicationLoad() and [NSApp run] and NSApplicationMain(),
but usually it would just terminate the application about
a second after opening the initial window, prevent several
GUI objects from working (including window draggin), and/or
complain about being unable to connect some buttons (whatever
that means). Most of these were caused by using the
NSApplicationMain() thing, so I guess that's a pure Interface-
Builder function; but NSApplicationLoad() didn't work better
than the straightforward way either (or maybe it was even worse,
I was too pissed to really pay attention).

I was trying to find information telling me what SHOULD happen
if I select Quit from the Application menu (maybe I'm just missing
an implementation of NSApplication:Quit or something) but so far all
I could find was related to Apple Events, and I'm not getting the
applicationShouldTerminate: described there from either the dock or
the menu "Quit".

I guess I'll have to stick to the "empty app menu with my own
quit-menu" workaround until I accidentally stumble across a solution,
along with a check to alert me if it runs on my box and sees a non-nil
mainMenu :-)
This stupid menu thing is turning into a big waste of time...  :-(

Although, something I still want to try some time is to use
Interface-Builder to just make a dummy menu to kickstart things,
load that, and see it if helps.

Thanks for the pointer,
  Christian

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [NSapp mainMenu] returns nil
      • From: William Bumgarner <email@hidden>
    • Re: [NSapp mainMenu] returns nil - Solution :-)
      • From: Christian Stieber <email@hidden>
References: 
 >Re: [NSapp mainMenu] returns nil (From: Christian Stieber <email@hidden>)

  • Prev by Date: NSProgressIndicator, runModalForWindow, detachNewThreadSelector -> Not good...
  • Next by Date: Re: Displaying date in Core Data application
  • Previous by thread: Re: [NSapp mainMenu] returns nil
  • Next by thread: Re: [NSapp mainMenu] returns nil - Solution :-)
  • Index(es):
    • Date
    • Thread