• 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: Getting hitTest of Subview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting hitTest of Subview


  • Subject: Re: Getting hitTest of Subview
  • From: j o a r <email@hidden>
  • Date: Sat, 2 Nov 2002 13:42:10 +0100

On Saturday, Nov 2, 2002, at 12:23 Europe/Stockholm, Craig Bakalian wrote:

-(void)mouseUp: (NSEvent *) event
{
NSPoint loc = [event locationInWindow];
NSPoint vLoc = [self convertPoint: loc fromView: nil];
NSRect myRect = NSMakeRect(vLoc.x, vLoc.y, 100.0, 24.0);
CBNote *myNote = [[CBNote alloc] initWithFrame: myRect];
[self addSubview: myNote];
}

Don't forget to release the new subview, or else you will most likely leak! Something like this:

- (void) mouseUp: (NSEvent *) event
{
NSPoint loc = [self convertPoint: [event locationInWindow] fromView: nil];
CBNote *myNote = [[CBNote alloc] initWithFrame: NSMakeRect(loc.x, loc.y, 100.0, 24.0)];
[self addSubview: myNote];
[myNote release]; // The note is now only retained by it's superview
}

The CBNote is a subclass of NSView. It just draws a @"Hello World".
This works fine. OK, how do I get a hitTest for this added subview? I
feel lost in responders, locations, and superviews.

How do you mean "get a hitTest"? As soon as it is inserted in the superview it should get mouse click events automatically. If your CBNote class implements "mouseDown:" it should get called when you click it - is this not working?

j o a r
_______________________________________________
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: Getting hitTest of Subview
      • From: Craig Bakalian <email@hidden>
References: 
 >Getting hitTest of Subview (From: Craig Bakalian <email@hidden>)

  • Prev by Date: Getting hitTest of Subview
  • Next by Date: Re: Getting hitTest of Subview
  • Previous by thread: Getting hitTest of Subview
  • Next by thread: Re: Getting hitTest of Subview
  • Index(es):
    • Date
    • Thread