• 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
NSMenu update problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMenu update problem


  • Subject: NSMenu update problem
  • From: "Jens v.P." <email@hidden>
  • Date: Sun, 4 Apr 2004 18:12:37 +0200

Hi,

I've got a problem updating a NSMenu.
I have a NSMenu as a pull-down list in combination with a NSSearchView. I want the menu to show the recent searches, just like the Google-search bar in Safari.


I'm adding new entries on search and on other events. Unfortunately the menu is only updated after the user has activated the search view and pressed "return"  but the methods for inserting new NSMenuItems to the menu are always the same:

// Java code snippet, m_xSearch is the search view member field
void updateRecentSearches() {
	String strSearch = m_xSearch.stringValue().trim();
     if (strSearch==null || strSearch.length()==0)  return;

     NSSearchFieldCell cell = (NSSearchFieldCell) m_xSearch.cell();
     NSMenu menu = cell.searchMenuTemplate();

if (menu.indexOfItemWithTitle(strSearch)>=0)
return; // avoid duplicates

NSSelector sel = new NSSelector("onRecent", new Class[] {Object.class} );


	NSMenuItem item = new NSMenuItem(strSearch+" ", sel, "");
	item.setTarget(this);
	item.setEnabled(true);

menu.insertItemAtIndex(item,1);
m_xSearch.setNeedsDisplay(true); // is this necessary? it doesn't work...
}


The items are always added  but not displayed. They are displayed after selecting the search view and after "return" is pressed. But the method above is not only called on this event but also if text in another view is double clicked. In this latter case, the method is called, an item is inserted, but not displayed.

What is missing?

Best regards,

Jens
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Application generated via XCode refuses to launch under a different user.
  • Next by Date: Survey Says!
  • Previous by thread: Re: Application generated via XCode refuses to launch under a different user.
  • Next by thread: Survey Says!
  • Index(es):
    • Date
    • Thread