Re: Need the Why and How of mouseDragged:
Re: Need the Why and How of mouseDragged:
- Subject: Re: Need the Why and How of mouseDragged:
- From: "Adam R. Maxwell" <email@hidden>
- Date: Thu, 13 Dec 2007 08:18:51 -0800
On Thursday, December 13, 2007, at 07:35AM, "Alastair Houghton" <email@hidden> wrote:
>On 13 Dec 2007, at 14:30, Jerry Krinock wrote:
>
>> It seems that mouseDragged: would be more sensible method from which
>> to send dragImage:at:offset:eventpasteboard:source:slideBack:. But
>> I never get any mouseDragged:messages. Reading the list archives, I
>> get the impression that there might be some kind of trick to getting
>> these, but I can't find the trick.
>
>There's no trick here. The problem you're seeing is most likely that
>RBSplitView is running a mouse tracking loop when it gets -mouseDown:,
>which is eating all the -mouseDragged events.
>
>Unfortunately, if a view uses this style of mouse tracking, it's
>difficult to add additional code to do something different (unless the
>view has adequate hooks built into it) without modifying the original
>source code or re-implementing the existing behaviour.
I posted about this same problem a month or two ago, though with NSSplitView. It's odd that a container view that's useless without subviews would break mouse tracking for its subviews. Anyway, my fix was the following in an NSSplitView subclass, so maybe the same would work for RBSplitView? Corrections welcome.
- (void)mouseDown:(NSEvent *)theEvent {
BOOL inDivider = NO;
NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
NSArray *subviews = [self subviews];
int i, count = [subviews count];
id view;
NSRect divRect;
for (i = 0; i < count - 1; i++) {
view = [subviews objectAtIndex:i];
divRect = [view frame];
if ([self isVertical]) {
divRect.origin.x = NSMaxX(divRect);
divRect.size.width = [self dividerThickness];
} else {
divRect.origin.y = NSMaxY(divRect);
divRect.size.height = [self dividerThickness];
}
if (NSPointInRect(mouseLoc, divRect)) {
inDivider = YES;
break;
}
}
if (inDivider) {
[super mouseDown:theEvent];
} else {
[[self nextResponder] mouseDown:theEvent];
}
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden