Hi,

I am tracking the mouse pointer to dynamically resize a splitter as a separate drag handle is dragged. This is done in mouseDown: of the drag handle with a custom event loop. The loop looks like this:

    while (keepOn)
        {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
theEvent = [[self window] nextEventMatchingMask: NSAnyEventMask] ;// NSLeftMouseUpMask | NSLeftMouseDraggedMask];
                
        switch ([theEvent type])
                {
                        case NSLeftMouseUp:
                                keepOn = NO;
                                break;
                                
                        case NSLeftMouseDragged:
[nc postNotificationName:NSSplitViewWillResizeSubviewsNotification object:splitView];
                                firstFrame = [[[splitView subviews] 
objectAtIndex:0] frame];
                                firstFrame.size.width = (isLeftResizer ?
MAX(0,roundf(([splitViewconvertPoint:[theEvent locationInWindow] fromView:nil].x + offset) - firstFrame.origin.x)) : MAX(0,roundf([splitViewconvertPoint:[theEvent locationInWindow] fromView:nil].x - [splitViewdividerThickness] - offset)));

                                firstFrame.size.width = 
MIN(MAX(firstFrame.size.width,min),max);

                                NSLog( @"SetFrame: %@" , 
NSStringFromRect(firstFrame) ) ;
                                [[[splitView subviews] objectAtIndex:0] 
setFrame:firstFrame];
NSLog( @"\tIs Now: %@" , NSStringFromRect([[[splitView subviews] objectAtIndex:0] frame]) ) ;

                                [splitView adjustSubviews];
[nc postNotificationName:NSSplitViewDidResizeSubviewsNotification object:splitView];
                                break;
                        default:
                                break;
                }
        [pool release] ;
        }
        
NSLog( @"Finally: %@" , NSStringFromRect([[[splitView subviews] objectAtIndex:0] frame]) ) ;


(you might recognize this is as the Scrivener custom split view code available on the web)

Anyway, the visual updates to the screen seem to start lagging the further right I drag the handle. You can see the NSLog()s I have in the code; here is the output as I drag:

[...]
2009-03-10 14:37:42.428 SkootUI[8830:10b] SetFrame: {{0, 0}, {718, 604}}
2009-03-10 14:37:42.444 SkootUI[8830:10b]       Is Now: {{0, 0}, {718, 604}}
2009-03-10 14:37:42.511 SkootUI[8830:10b] SetFrame: {{0, 0}, {721, 604}}
2009-03-10 14:37:42.539 SkootUI[8830:10b]       Is Now: {{0, 0}, {721, 604}}
2009-03-10 14:37:42.596 SkootUI[8830:10b] SetFrame: {{0, 0}, {723, 604}}
2009-03-10 14:37:42.600 SkootUI[8830:10b]       Is Now: {{0, 0}, {723, 604}}
2009-03-10 14:37:44.101 SkootUI[8830:10b] Finally: {{0, 0}, {684, 604}}

As you can see, as far as the view being resized is concerned, it is being set to what I set it to as I drag the handle; i.e., the "SetFrame:" dimensions match the "Is Now:" dimensions. During this time, however, I can see the view sizing visually lag. When the drag finishes and the "Finally" block prints out, querying the view for its frame displays what I believe to be the actual lagged dimensions.

Can anyone tell me what's going on?

Thanks,

Mike
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to