• 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: event/notification for focus?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: event/notification for focus?


  • Subject: Re: event/notification for focus?
  • From: Shawn Erickson <email@hidden>
  • Date: Thu, 7 Apr 2005 11:48:27 -0700


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>

_______________________________________________
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


  • Follow-Ups:
    • Re: event/notification for focus?
      • From: Luc Vandal <email@hidden>
References: 
 >event/notification for focus? (From: Luc Vandal <email@hidden>)
 >Re: event/notification for focus? (From: Mike Ferris <email@hidden>)
 >Re: event/notification for focus? (From: Luc Vandal <email@hidden>)
 >Re: event/notification for focus? (From: Ricky Sharp <email@hidden>)
 >Re: event/notification for focus? (From: Luc Vandal <email@hidden>)
 >Re: event/notification for focus? (From: j o a r <email@hidden>)
 >Re: event/notification for focus? (From: Luc Vandal <email@hidden>)
 >Re: event/notification for focus? (From: j o a r <email@hidden>)
 >Re: event/notification for focus? (From: Luc Vandal <email@hidden>)
 >Re: event/notification for focus? (From: Shawn Erickson <email@hidden>)

  • Prev by Date: Re: Reordering views
  • Next by Date: NSTabView in NSToolbar
  • Previous by thread: Re: event/notification for focus?
  • Next by thread: Re: event/notification for focus?
  • Index(es):
    • Date
    • Thread