NSMenu update problem
NSMenu update problem
- Subject: NSMenu update problem
- From: "Jens v.P." <email@hidden>
- Date: Mon, 5 Apr 2004 13:54:02 +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.
_______________________________________________
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.