Re: MouseDown of superclass
Re: MouseDown of superclass
- Subject: Re: MouseDown of superclass
- From: j o a r <email@hidden>
- Date: Thu, 20 Mar 2003 12:36:51 +0100
I would bet that this is what they do, and why you see this behaviour:
<file:///Developer/Documentation/Cocoa/TasksAndConcepts/
ProgrammingTopics/BasicEventHandling/Tasks/HandlingMouseEvents.html>
You should most likely implement a similar loop, and only call super
when you have decided that you aren't interested in a particular event.
Something like this:
- (void) mouseDown:(NSEvent *) event
{
NSEvent *newEvent = nil;
while ((newEvent = [[self window] nextEventMatchingMask:
NSLeftMouseUpMask | NSLeftMouseDraggedMask]))
{
switch ([newEvent type])
{
case NSLeftMouseDragged:
[[self window] postEvent: newEvent atStart: NO];
[super mouseDown: event];
return;
case NSLeftMouseUp:
{
// Do something here
return;
}
default:
/* Ignore any other kind of event. */
break;
}
}
}
j o a r
On Thursday, Mar 20, 2003, at 12:23 Europe/Stockholm, Tobias Hermann
wrote:
I have a subclass of NSBrowser. In that subclass, I override the
mouseDown, mouseUp and mouseDragged method, in order to alter it's
behaviour for some situations (not for all!). For the things I want to
let handle the original NSBrowser, I call [super mouseXXXX: event];
(down, dragged or up).
Now something strange happens:
When I call [super mouseDown: event]; within my own mouseDown method,
i get no mouseDragged or mouseUp events anymore... It seems that the
super class NSBrowser grabs the control of the program within its
mouseDown method UNTIL THE MOUSE BUTTON IS RELEASED!
Proof: my mouseDown method:
- (void) mouseDown: (NSEvent *) event
{
NSLog(@"mouse down IN");
[super mouseDown: event];
NSLog(@"mouse down OUT");
}
When pressing the left mouseButton, I get an "mouse down IN" only. The
correct behavior in MY opinion would be that I also should get a
"mouse down OUT" immediately. But i get it AFTER i released the mouse
button. And i don't get any mouseDragged and mouseUp events at all!
Why is that? I tested this with a subclass of NSOutlineView as well
and it was the same thing there...
Why does the mouseDown method of these classes grab the control of the
program and makes his own event loop handling during its runtime?
That seems really odd. For example if you just want to do some stuff
in mouseDragged or mouseUp, you have to override mouseDown (and do NOT
call super mousedown!!) and implement all what the original mouseDown,
mouseDragged and mouseUp routines would have done!
Any ideas?
_______________________________________________
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.