FROM : Peter Ammon
DATE : Fri Jan 04 21:30:37 2008
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
DATE : Fri Jan 04 21:30:37 2008
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
| Related mails | Author | Date |
|---|---|---|
| Hendrik Holtmann | Jan 4, 15:20 | |
| Peter Ammon | Jan 4, 21:30 | |
| Pierre Bernard | Feb 6, 00:43 | |
| Pierre Bernard | Feb 6, 09:37 | |
| Ron Fleckner | Feb 6, 11:33 | |
| Pierre Bernard | Feb 6, 11:38 | |
| Lieven Dekeyser | Feb 15, 13:55 |






Cocoa mail archive

