Re: Set focus on NSTextField in an NSMenuItem
Re: Set focus on NSTextField in an NSMenuItem
- Subject: Re: Set focus on NSTextField in an NSMenuItem
- From: Dragan Milić via Cocoa-dev <email@hidden>
- Date: Tue, 18 Oct 2022 20:20:37 +0200
> On 18. 10. 2022., at 19:11, Alex Zavatone wrote:
>
> I am speaking from an iOS perspective but, is there something like
> makeFirstResponder?
Yes, there is. It should be sent to an NSWindow instance and I tried to do that
in -[NSMenuDelegate menuNeedsUpdate:], or -[NSMenuDelegate menuWillOpen:] (in
both cases after some delay, as the window of the text field is still set at
the time those delegate messages are received) and I also subclassed NSTextView
and tried to call -[[self window] makeFirstResponder:self] in overridden
-[NSView viewDidMoveToWindow] method, but those calls have no effect. Even if
it worked, it’d still be a problem setting the focus on the text field by
clicking on it.
-- Dragan
_______________________________________________
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