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 protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to