Index: Source/NSColorWell.m =================================================================== --- Source/NSColorWell.m (revision 29108) +++ Source/NSColorWell.m (working copy) @@ -46,8 +46,6 @@ static NSString *GSColorWellDidBecomeExclusiveNotification = @"GSColorWellDidBecomeExclusiveNotification"; -static NSPoint _lastMouseDownPoint; - @implementation NSColorWell /* @@ -102,6 +100,7 @@ object: nil]; _is_active = YES; + [[self cell] setHighlighted: YES]; [colorPanel setColor: _the_color]; [colorPanel orderFront: self]; @@ -124,6 +123,7 @@ - (void) deactivate { _is_active = NO; + [[self cell] setHighlighted: NO]; [[NSNotificationCenter defaultCenter] removeObserver: self]; @@ -147,6 +147,10 @@ NSDragOperation sourceDragMask; NSDebugLLog(@"NSColorWell", @"%@: draggingEntered", self); + + if ([self isEnabled] == NO) + return NSDragOperationNone; + sourceDragMask = [sender draggingSourceOperationMask]; pb = [sender draggingPasteboard]; @@ -285,39 +289,89 @@ - (void) mouseDown: (NSEvent *)theEvent { + BOOL done; + BOOL inside; + BOOL startedInWell; + NSPoint point; + // // OPENSTEP 4.2 and OSX behavior indicates that the colorwell doesn't // work when the widget is marked as disabled. // - if ([self isEnabled]) + if ([self isEnabled] == NO) + return; + + // + // Unbordered color wells start a drag immediately upon mouse down + // + if ([self isBordered] == NO) { - _lastMouseDownPoint = - [self convertPoint: [theEvent locationInWindow] - fromView: nil]; + [NSColorPanel dragColor: _the_color + withEvent: theEvent + fromView: self]; + return; + } - if (_is_active == NO) + point = [self convertPoint: [theEvent locationInWindow] + fromView: nil]; + startedInWell = [self mouse: point inRect: _wellRect]; + + [[self cell] setHighlighted: ![self isActive]]; + [self setNeedsDisplay: YES]; + + done = NO; + while (!done) + { + theEvent = [[self window] nextEventMatchingMask: + NSLeftMouseUpMask | NSLeftMouseDraggedMask]; + point = [self convertPoint: [theEvent locationInWindow] + fromView: nil]; + inside = [self mouse: point inRect: [self bounds]]; + + switch ([theEvent type]) { - [self activate: YES]; + case NSLeftMouseDragged: + if (startedInWell) + { + [[self cell] setHighlighted: [self isActive]]; + [self setNeedsDisplay: YES]; + + [NSColorPanel dragColor: _the_color + withEvent: theEvent + fromView: self]; + done = YES; + } + else + { + [[self cell] setHighlighted: inside ^ [self isActive]]; + [self setNeedsDisplay: YES]; + } + break; + case NSLeftMouseUp: + if (inside) + { + if (_is_active == NO) + { + [self activate: YES]; + } + else + { + [self deactivate]; + } + } + else + { + [[self cell] setHighlighted: [self isActive]]; + [self setNeedsDisplay: YES]; + } + done = YES; + break; + default: + break; } - else - { - [self deactivate]; - } } } -- (void) mouseDragged: (NSEvent *)theEvent -{ - if ([self isEnabled]) - { - if ([self mouse: _lastMouseDownPoint inRect: _wellRect]) - { - [NSColorPanel dragColor: _the_color - withEvent: theEvent - fromView: self]; - } - } -} - (BOOL) performDragOperation: (id )sender { Index: Source/GSThemeDrawing.m =================================================================== --- Source/GSThemeDrawing.m (revision 29108) +++ Source/GSThemeDrawing.m (working copy) @@ -728,7 +728,7 @@ /* * Fill in control color. */ - if ([well isActive]) + if ([[well cell] isHighlighted]) { [[NSColor selectedControlColor] set]; } Index: Source/NSColorPanel.m =================================================================== --- Source/NSColorPanel.m (revision 29108) +++ Source/NSColorPanel.m (working copy) @@ -356,7 +356,7 @@ - (void) _updatePicker: (id) sender { - [_currentPicker setColor: [_colorWell color]]; + [self setColor: [_colorWell color]]; } - (void) _bottomWellAction: (id) sender