• 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
weird side effect with setSubmenu in Main menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

weird side effect with setSubmenu in Main menu


  • Subject: weird side effect with setSubmenu in Main menu
  • From: jerome LAURENS <email@hidden>
  • Date: Wed, 17 Apr 2002 19:29:59 +0200

Hi all,

I have a menu item of the main menu which gives access to the contents
of a whole directory (with submenus a la bihierarchic...) As it is
dynamically created at startup, it takes a very long time for my app to
launch, due to the fact that the listed folder contains thousands of
files. So i decided to create the list menu in a separate thread, then
connect the submenu at the right location in the main menu.

It kind of works, the first visible thing is that i can now use the main
menu without waiting. In fact,
when i launch my app and wait for a while, nothing weird occurs, but my
multithreaded strategy is a nonsense.
But, when i launch my app and do not wait, making the main menu to pop
very early (opening for example a recent doc), When my app tries to
insert the list menu in the main menu, all the items of the list menu
become disabled, even those with submenus!!! So I used something to
force enabling the menu items like

@implementation NSMenu(foo)
- (void) deepEnableItems;
{
NSEnumerator * E = [[self array] objectEnumerator];
NSMenuItem * MI;
while(MI = [E nextObject])
{
if([MI hasSubmenu])
{
[[MI submenu] deepEnableItems];
}
else if([MI action] != NULL])
{
[MI setEnabled: YES];
if(! [MI isEnabled])
{
[MI setEnabled: YES];
NSLog(@"%@ %@", MI, ([MI isEnabled]? @"YES": "NO"));
}
}
}
}
@end

calling

[myMenu deepEnableItems];/* nothing is logged */
[myMenuItem setSubmenu: myMenu];
[myMenu deepEnableItems];/* thousands of NO appear.... only if i pop the
main menu before this call*/

What a nonsense!

How could i manage that?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Using Carbon in Cocoa App
  • Next by Date: Re: Hello, a book recommendation request, and a question
  • Previous by thread: Re: [ANN] Cocoa Browser ver 0.3
  • Next by thread: toggleToolbarShown and titlebar widget
  • Index(es):
    • Date
    • Thread