Skip navigation.
 
mlRe: event/notification for focus?
FROM : Shawn Erickson
DATE : Thu Apr 07 20:48:27 2005

On Apr 7, 2005, at 10:29 AM, Shawn Erickson wrote:

>
> On Apr 7, 2005, at 10:07 AM, Luc Vandal wrote:
>

>> I just want to be able to run a function when the focus (or should I 
>> use the term first responder? I'm confused) changes to another 
>> control.

>
> What will that function do is what we are trying to understand? What 
> do you need to do that depends on which control is currently at the 
> head of the responder chain.
>
> It goes to division of responsibility in your application and that you 
> may be trying to mix across the lines, paradigm if you will, that 
> Cocoa (AppKit) outlines.


As an example of an alternate would using a tracking rectangle be a 
better fit?

<http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSView.html#//apple_ref/doc/uid/
20000014/BBCCGCGB
>

Or a simple target-action type connection?
(relevance depends on the control type involved in your question)

Or NSControlTextDidBeginEditingNotification?
(relevance depends on the control type involved in your question)

etc.

(looking back over prior emails...)

If you really want this type of information you may have to subclass 
NSWindow and use your NSWindow subclass in your code / nibs. In your 
subclass override makeFirstResponder: [1] and add your notification, 
responder tracking, etc. code here. That should get you into the loop 
with first responder changes (which may be what Dustin did in his 
NSWindow subclass).

Another possibility it to plug yourself in via the sendEvent: chain 
(likely at NSApplication level) and if you see events that could change 
the first responder then message the window affected with 
firstResponder and compare to what it was before the event.

Or as Mike outline NSWindowDidUpdate may be the best way to know when 
to check if the responder may have changed.

(or I could be missing something more obvious)

As always if you find an aspect of Cocoa to be lacking consider filing 
a report about it with Apple <http://developer.apple.com/bugreporter/
but keep in mind that Cocoa has existed for a very long time without 
such notification, in other words evaluate if a better more Cocoa 
friendly ways exists to achieve what you are after (which is what we 
have been trying to help you find).

-Shawn

[1] 
<http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSWindow.html#//apple_ref/doc/uid/
20000013/BABBDHFF
>

Related mailsAuthorDate
mlevent/notification for focus? Luc Vandal Apr 6, 20:57
mlRe: event/notification for focus? Ricky Sharp Apr 6, 21:58
mlRe: event/notification for focus? ttempel Apr 7, 00:48
mlRe: event/notification for focus? Luc Vandal Apr 7, 01:58
mlRe: event/notification for focus? Dustin Voss Apr 7, 02:22
mlRe: event/notification for focus? Mike Ferris Apr 7, 16:41
mlRe: event/notification for focus? Luc Vandal Apr 7, 17:50
mlRe: event/notification for focus? Ricky Sharp Apr 7, 17:58
mlRe: event/notification for focus? Luc Vandal Apr 7, 18:26
mlRe: event/notification for focus? j o a r Apr 7, 18:36
mlRe: event/notification for focus? Shawn Erickson Apr 7, 18:41
mlRe: event/notification for focus? Luc Vandal Apr 7, 18:46
mlRe: event/notification for focus? j o a r Apr 7, 18:51
mlRe: event/notification for focus? Luc Vandal Apr 7, 19:07
mlRe: event/notification for focus? Ricky Sharp Apr 7, 19:15
mlRe: event/notification for focus? Shawn Erickson Apr 7, 19:29
mlRe: event/notification for focus? Shawn Erickson Apr 7, 20:48
mlRe: event/notification for focus? Luc Vandal Apr 7, 22:02
mlRe: event/notification for focus? Luc Vandal Apr 8, 18:06
mlRe: event/notification for focus? Shawn Erickson Apr 8, 18:18
mlRe: event/notification for focus? Shawn Erickson Apr 8, 18:22
mlRe: event/notification for focus? Luc Vandal Apr 8, 18:29
mlRe: event/notification for focus? Shawn Erickson Apr 8, 18:43
mlRe: event/notification for focus? Luc Vandal Apr 8, 18:46
mlRe: event/notification for focus? Luc Vandal Apr 8, 19:17
mlRe: event/notification for focus? Shawn Erickson Apr 8, 19:33
mlRe: event/notification for focus? Luc Vandal Apr 8, 21:35
mlRe: event/notification for focus? Shawn Erickson Apr 8, 21:45