FROM : Craig Bakalian
DATE : Sat Nov 02 23:42:03 2002
On Saturday, November 2, 2002, at 07:42 AM, j o a r wrote:
> 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
>
Well, hold on here,
I was doing the hitTest in the wrong subclass. The hitTest needed to
be in the superview so the mouseDown would not create an instance on
top of another instance. So this is what I did-
-(void)mouseDown: (NSEvent *) event
{
NSPoint loc = [event locationInWindow];
NSPoint vLoc = [self convertPoint: loc fromView: nil];
NSView *Note;
Note = [self hitTest: vLoc];
if(Note == self){
NSRect myRect = NSMakeRect(vLoc.x, vLoc.y, 100.0, 24.0);
CBNote *myNote = [[CBNote alloc] initWithFrame: myRect];
[self addSubview: myNote];
[myNote release];
}
}
No big thrill here, I just couldn't figure out what hitTest was
returning. But, I think, on the CBNote.m I had to do the below code to
make certain it's mouseDown would change it's string property.
-(void)mouseDown: (NSEvent *) event
{
[self setString: @"Good Bye"];
[self setNeedsDisplay: YES];
}
-(BOOL)acceptsFirstResponder
{
return YES;
}
I think I need to set the acceptsFirstResponder to get the mouseDown
before the superview does, because this is a subview?
Craig Bakalian
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Sat Nov 02 23:42:03 2002
On Saturday, November 2, 2002, at 07:42 AM, j o a r wrote:
> 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
>
Well, hold on here,
I was doing the hitTest in the wrong subclass. The hitTest needed to
be in the superview so the mouseDown would not create an instance on
top of another instance. So this is what I did-
-(void)mouseDown: (NSEvent *) event
{
NSPoint loc = [event locationInWindow];
NSPoint vLoc = [self convertPoint: loc fromView: nil];
NSView *Note;
Note = [self hitTest: vLoc];
if(Note == self){
NSRect myRect = NSMakeRect(vLoc.x, vLoc.y, 100.0, 24.0);
CBNote *myNote = [[CBNote alloc] initWithFrame: myRect];
[self addSubview: myNote];
[myNote release];
}
}
No big thrill here, I just couldn't figure out what hitTest was
returning. But, I think, on the CBNote.m I had to do the below code to
make certain it's mouseDown would change it's string property.
-(void)mouseDown: (NSEvent *) event
{
[self setString: @"Good Bye"];
[self setNeedsDisplay: YES];
}
-(BOOL)acceptsFirstResponder
{
return YES;
}
I think I need to set the acceptsFirstResponder to get the mouseDown
before the superview does, because this is a subview?
Craig Bakalian
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Craig Bakalian | Nov 2, 12:23 | |
| j o a r | Nov 2, 13:42 | |
| j o a r | Nov 2, 13:55 | |
| Craig Bakalian | Nov 2, 23:42 | |
| j o a r | Nov 3, 00:53 |






Cocoa mail archive

