• 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: menuNeedsUpdate delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: menuNeedsUpdate delegate


  • Subject: Re: menuNeedsUpdate delegate
  • From: Boyd Collier <email@hidden>
  • Date: Sun, 19 Mar 2006 12:07:49 -0800

I created a very small app to see if I could figure out why this was happening but thus far haven't figured it out. Upon launch, my app opens a blank, untitled document window, which is pretty standard, and typing into this window results in menuNeedsUpdate: being called after every character, even if I've not touched any menu.

Here's the code for my menuNeedsUpdate: method, which works very nicely for creating a hierarchical menu of names of document windows on the fly:

- (void)menuNeedsUpdate:(NSMenu *)menu {
NSLog(@"menuNeedsUpdate was called");
NSMenu* menuOfDocNames = [[[NSMenu alloc] init] autorelease];
NSDocumentController *sdc;
sdc = [NSDocumentController sharedDocumentController];
NSArray *arrayOfDocuments = [sdc documents];
int numberOfDocs = [arrayOfDocuments count];
NSLog(@"number of document windows now showing = %i", numberOfDocs);
NSDocument *aDocument;
NSString *nameOfWindow;
int index = numberOfDocs-1;
for (index; index >= 0; index--)
{
aDocument = (NSDocument*)[arrayOfDocuments objectAtIndex:index];
nameOfWindow = [aDocument displayName];
NSMenuItem *aMenuItem = [[NSMenuItem alloc] initWithTitle:nameOfWindow action:@selector(docWindowsAction:) keyEquivalent:@""];
[aMenuItem autorelease];
[aMenuItem setTarget:self];
[menuOfDocNames addItem:aMenuItem];
}
[menuOfDocNames setAutoenablesItems:NO];
[[menu itemAtIndex:[menu indexOfItemWithTag:777]] setSubmenu:menuOfDocNames];
NSLog(@"end menuNeedsUpdate");
}


If I comment out [[menu itemAtIndex:[menu indexOfItemWithTag:777]] setSubmenu:menuOfDocNames];
then menuNeedsUpdate: isn't called when I type into an open document window. Any insights into what is happening would be appreciated.


Thanks again, Boyd


On Mar 17, 2006, at 8:28 PM, Boyd Collier wrote:

Matt,

Thanks for seeing if you could reproduce this. Yes, I meant every time
I type a character. I'm going to make a copy of my app and strip out
all the irrelevant code to see if I can get a better idea about what's
going on.

Boyd

On Mar 17, 2006, at 10:24 AM, Matt Neuburg wrote:

On Thu, 16 Mar 2006 16:45:12 -0800, Boyd Collier
<email@hidden> said:
In response to the question posted by Rudi Sherry earlier today, I
looked at a document-based program I've been working on to remind
myself of what I did regarding keeping the text current. Separately,
in the same program, I update a hierarchical menu so that it shows
the names of all the open document windows. I do this by using a
menuNeedsUpdate delegate. In my code for this method, I put a brief
message in the run log (for debugging purposes). Much to my
surprise, this shows that menuNeedsUpdate gets called every time I
type into a document window, even though in Interface Builder, the
delegate is connected between the menu that I want to update and my
AppController, and would seem to have nothing to do with typing in a
document window. Obviously, I don't understand something (not
unusual for me). I reread Anguish et al. on delegates and still
don't understand why typing in a document window would cause
menuNeedsUpdate to be called.

I can't reproduce this. When you say "every time I type", do you mean every
time you type a character, or every time you switch to a document window and
start typing in it? Also, what menu is it that you've set the delegate of?
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
_______________________________________________
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


References: 
 >Re: menuNeedsUpdate delegate (From: Matt Neuburg <email@hidden>)
 >Re: menuNeedsUpdate delegate (From: Boyd Collier <email@hidden>)

  • Prev by Date: closing panel from a thread
  • Next by Date: Re: CoreData : fundamental (or not) questions
  • Previous by thread: Re: menuNeedsUpdate delegate
  • Next by thread: Crash in removeObserver
  • Index(es):
    • Date
    • Thread