NSMenu problems
NSMenu problems
Hello!
I've got a couple of problems with NSMenu.
1) All menu items have a custom view. Therefore the default action for
the menu item never gets called. Instead, I'm catching the mouse up
event in my custom view and call the appropriate selector from there.
This works fine. The problem I'm having is when navigating the menu
with the keyboard. When I select a menu item and hit return the menu
is simply dismissed. I have tried catching the keyboard event but have
no idea where it goes. It is not catched by the custom view, nor the
menu's delegate or app controller.
2) The menu has a custom search field as its first item. When I press
the arrow down key I'd like it to select the menu item under the
search field (this is a regular NSMenuItem). I can catch the moveDown:
command in the text field's
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView
doCommandBySelector:(SEL)command
delegate method. But I cannot find any way to programmatically select
a menu item. I dug around in AppKit and found a private method named
_setHighlightedItem:informingDelegate:. This method does indeed seem
to change the selection, sort of: when I log the current selection it
reports the correct menu item. But it doesn't visually highlight this
item. I also tried simulating a arrow key down/up event (after setting
the first responder to the menu's window) but it didn't work either.
3) When typing in the search field, the menu is updated to show the
search results. This means the width of the menu is expanded to fit
the new items. But when I clear the search field and the menu items
are reset to their default values, the menu doesn't shrink again.
Calling the deprecated sizeToFit method has no effect.
I hope you can help me out here. Thanks.
Kind regards,
Fabian
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden