Re: NSTextfield focus in contextual menu
Re: NSTextfield focus in contextual menu
- Subject: Re: NSTextfield focus in contextual menu
- From: Kyle Sluder <email@hidden>
- Date: Thu, 17 Jan 2013 11:54:04 -0800
On Thu, Jan 17, 2013, at 11:38 AM, Tamas Nagy wrote:
> Hi List,
>
> I have an application (10.6>) where are have a contextual menu with an
> NSTextfield. What I'm trying is when I displaying the menu with [NSMenu
> popupContextual…] making the NSTextfield focused, but without luck.
>
> I tried setting [mytextfield becomeFirstResponder] and [mytestfield
> selectText:nil] before the popup method called, but it not works - I'm
> not sure this is technology even possible.
Sadly, views-in-menus is a generally broken technology. It's good for
drawing custom content, but that's about it.
If you want to do this, you'll probably want to build a custom
NSMenu-lookalike. This is how Spotlight is implemented, for example.
Alternatively, you may be able to subclass -[NSApplication sendEvent:]
and feed the right data to the text field on your menu. I've heard
rumblings that this is how Xcode implements its typeahead searching in
menus.
--Kyle Sluder
_______________________________________________
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