Custom window resizer: flicker
Custom window resizer: flicker
- Subject: Custom window resizer: flicker
- From: Claudio Procida <email@hidden>
- Date: Fri, 24 Nov 2006 15:11:57 +0100
I'm using a custom view as a resizer for an odd-shaped window. It
implements a modal event loop as illustrated in the Cocoa Event
Handling Guide.
The following code seems to do the work, but at some point, when the
mouse has been dragged for a certain distance, the window "flickers".
The vertical size varies rapidly, resulting in a trembling visual
effect.
The horizontal size changes smoothly as expected. What's wrong with
this code?
- (void)mouseDown:(NSEvent *)theEvent
{
BOOL keepOn = YES;
NSPoint startPoint;
NSWindow *parent;
NSRect oldRect;
NSPoint currentPoint;
parent = [self window];
oldRect = [parent frame];
startPoint = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
while (keepOn) {
theEvent = [parent nextEventMatchingMask: NSLeftMouseUpMask |
NSLeftMouseDraggedMask];
currentPoint = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
switch ([theEvent type]) {
case NSLeftMouseDragged:
{
NSSize delta = NSMakeSize(currentPoint.x - startPoint.x,
currentPoint.y - startPoint.y);
NSRect newRect = NSMakeRect(oldRect.origin.x,
oldRect.origin.y + delta.height,
oldRect.size.width + delta.width,
oldRect.size.height - delta.height);
[parent setFrame:newRect display:YES];
break;
}
case NSLeftMouseUp:
keepOn = NO;
break;
default:
/* Ignore any other kind of event. */
break;
}
};
return;
}
--
Claudio Procida
Emeraldion Lodge
http://www.emeraldion.it
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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