discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem updating a (sub)menu


From: Chris Vetter
Subject: Problem updating a (sub)menu
Date: Thu, 6 Oct 2005 09:47:40 +0200 (MEST)

Hi,

I'm having a problem with updating a submenu:

What I'm trying to do is implement a "Recent Files" submenu.

When I open a file/document in one application, I'm sending a notification
about it, that is picked up by the other application. I can retrieve the
file/document name and when I use -insertItemWithTitle:... it is added to
the submenu, according to -itemArray. I can even retrieve the -indexOfItem:

However, the submenu on screen never gets updated, that is, the entry is
never shown, even if I use -update on the submenu or the main menu.

Here's a short example of what I do:

// -updateRecentMenu: is called, when the observer receives a notification

- (void) updateRecentMenu: (NSNotification *) note
{
  NSString *entry = [[note userInfo] objectForKey: @"DocumentName"];

  NSLog(@"--> %d %@", [[recent itemArray] count], [recent itemArray]);
  NSLog(@"--> %@", entry);

  [recentMenu insertItemWithTitle: entry
                           action: NULL
                    keyEquivalent: nil
                          atIndex: 0]; // add at top of list

  // FIXME: remove bottom entry, if -itemArray > 8

  NSLog(@"--> %d %@", [[recent itemArray] count], [recent itemArray]);

  [recentMenu update];
  [mainMenu update];

  return;
}

The first NSLog shows no entries in -itemArray, the second shows the correct
name of the file, the third NSLog shows that one NSMenuItem HAS been added
-- which I figure should now be displayed, but it isn't.

What am I missing?

-- 
Chris Vetter

-- 
GMX DSL = Maximale Leistung zum minimalen Preis!
2000 MB nur 2,99, Flatrate ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]