• 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: NSWindow's firstResponder and a pointer to that object.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSWindow's firstResponder and a pointer to that object.


  • Subject: Re: NSWindow's firstResponder and a pointer to that object.
  • From: Johan Kool <email@hidden>
  • Date: Sat, 10 Jan 2004 01:44:32 +0100

On Jan 9, 2004, at 03:43, Dustin Voss wrote:

On 8 Jan, 2004, at 9:10 AM, Johan Kool wrote:

Hello,

I can't find this anywhere. I am implementing an inspector and are listening for NSWindowDidBecomeMainNotification notifications. This gets me the current window, so now I would be interested in which object is the firstResponder. With [myWindow firstResponder] I get back a NSResponder, but with that pointer I can't send function calls to the firstResponder. I tried to send notifications from my view when it loses the firstResponder state, but as every window has a firstResponder, this only works when I have multiple views or when I create a new window.

So my question is: How do I get a pointer to myView in myWindow knowing that myView is the firstResponder and having a pointer to myWindow?

Related to this: How do I test that a pointer is to an object of a certain class?

This shouldn't be a problem. [myWindow firstResponder] returns a pointer to an NSResponder. This does not mean that the object is an NSResponder, and only an NSResponder. It just means that the object can be treated as an NSResponder. The object will actually be an NSView (or your sub-class of NSView). Specifically, it will be myView. NSView inherits from NSResponder, so of course you can call NSResponder selectors, but you can also call NSView selectors.

If you want to check to see if the object is of a certain class, use the following code:

[object isKindOfClass:[ACertainClass class]]

This will return true if object is an instance of ACertainClass or of a sub-class of ACertainClass. If you want to exclude sub-classes for some reason, use isMemberOfClass: instead of isKindOfClass:.


Thanks for your clarification! I should have known this. Stupid me! :-)

I was looking to see if a window/view posts notifications about changes in the firstResponder. Am I right there is no such thing unless I implement it into my subclasses myself?

Johan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSWindow's firstResponder and a pointer to that object.
      • From: Dustin Voss <email@hidden>
References: 
 >NSWindow's firstResponder and a pointer to that object. (From: Johan Kool <email@hidden>)
 >Re: NSWindow's firstResponder and a pointer to that object. (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: vImage
  • Next by Date: Re: Special keystrokes recording
  • Previous by thread: Re: NSWindow's firstResponder and a pointer to that object.
  • Next by thread: Re: NSWindow's firstResponder and a pointer to that object.
  • Index(es):
    • Date
    • Thread