Re: Knowing if a view is first responder
Re: Knowing if a view is first responder
- Subject: Re: Knowing if a view is first responder
- From: glenn andreas <email@hidden>
- Date: Tue, 5 Apr 2005 09:38:57 -0500
On Apr 5, 2005, at 9:27 AM, Michael Becker wrote:
Hello,
is there any way to determine if a view is first responder? Right now,
I have subclassed NSView and overrode -becomeFirstResponder and
-resignFirstResponder to set an instance variable which I can query
with my own added method -isFirstResponder. Am I reinventing the wheel
here?
Regards,
Michael
You just need to check two things - is the view the firstResponder of
the window, and is the window the key window (since deactivated windows
still have first responders)
if ([[self window] isKeyWindow] && [[[self window] firstResponder] ==
self)
The various [will/should/did][become/resign]FirstResponder calls only
apply within changes the window, and not when another window becomes
active, so just handling things there isn't enough... (so if you need
to force your view to redraw to reflect this change you need to
explicitly listen to the window activation notifications).
Glenn Andreas email@hidden
<http://www.gandreas.com/> oh my!
quadrium | build, mutate, evolve | images, textures, backgrounds, art
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden