• 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
Re: Set focus on NSView in an NSMenuItem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set focus on NSView in an NSMenuItem


  • Subject: Re: Set focus on NSView in an NSMenuItem
  • From: Peter Ammon <email@hidden>
  • Date: Fri, 4 Jan 2008 12:30:37 -0800


On Jan 4, 2008, at 6:20 AM, Hendrik Holtmann wrote:

Hi everyone,

I got another question regarding the new setView method in Leopard.
Let's assume I set the view for an NSMenuItem to myView. myView contains an NSTextField. Now when I open the NSMenu I want to set the focus on this textfield, so the user can directly enter some text without having to click on the control first (like it works in the spotlight menu). How can I achieve that? I know how to call keyOrderAndFront and setFirstRespinder for NSWindows but how can I do this with an NSMenu. Setting the firstresponder for myView to the NSTextField does not help unfortunately.

Probably the easiest approach would be to override viewDidMoveToWindow on the view that will be in the menu, and from within it call [[self window] makeFirstResponder:self];. makeFirstResponder is one of a very few methods that is safe to call on the menu window.


-Peter

_______________________________________________

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


References: 
 >Set focus on NSView in an NSMenuItem (From: Hendrik Holtmann <email@hidden>)

  • Prev by Date: Re: Selecting an object of a NSArrayController
  • Next by Date: cascading windows in document architecture
  • Previous by thread: Set focus on NSView in an NSMenuItem
  • Next by thread: Trapping user shutdown/logout/restart in Cocoa/Foundation tool
  • Index(es):
    • Date
    • Thread