• 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
Custom window resizer: flicker
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Custom window resizer: flicker
      • From: Michael Nickerson <email@hidden>
    • [SOLVED] Re: Custom window resizer: flicker
      • From: Claudio Procida <email@hidden>
  • Prev by Date: Re: NSString, path and "/" char
  • Next by Date: How do I give a set of methods to some objects but not others?
  • Previous by thread: Re: NSView disable anti-aliasing ?
  • Next by thread: [SOLVED] Re: Custom window resizer: flicker
  • Index(es):
    • Date
    • Thread