mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 21:57:39 +00:00
Finish NSColorWell interaction tweaks:
- activation of the now happens on mouseUp, not mouseDown - non-bordered NSColorWells can't be activated by clicking - non-bordered NSColorWells start a drag operation upon mouseDown - disabled NSColorWells don't accept colours being dropped on them - dropping a colour on the well inside the NSColorPanel now also updates the active NSColorWell Also moved the static variable for keeping track of where the mouseDown occurred to an instance variable. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29150 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c1086efcd0
commit
ab285b8ea4
5 changed files with 82 additions and 22 deletions
|
@ -46,8 +46,6 @@
|
|||
static NSString *GSColorWellDidBecomeExclusiveNotification =
|
||||
@"GSColorWellDidBecomeExclusiveNotification";
|
||||
|
||||
static NSPoint _lastMouseDownPoint;
|
||||
|
||||
@implementation NSColorWell
|
||||
|
||||
/*
|
||||
|
@ -147,6 +145,10 @@ static NSPoint _lastMouseDownPoint;
|
|||
NSDragOperation sourceDragMask;
|
||||
|
||||
NSDebugLLog(@"NSColorWell", @"%@: draggingEntered", self);
|
||||
|
||||
if ([self isEnabled] == NO)
|
||||
return NSDragOperationNone;
|
||||
|
||||
sourceDragMask = [sender draggingSourceOperationMask];
|
||||
pb = [sender draggingPasteboard];
|
||||
|
||||
|
@ -289,12 +291,65 @@ static NSPoint _lastMouseDownPoint;
|
|||
// OPENSTEP 4.2 and OSX behavior indicates that the colorwell doesn't
|
||||
// work when the widget is marked as disabled.
|
||||
//
|
||||
if ([self isEnabled])
|
||||
{
|
||||
_lastMouseDownPoint =
|
||||
[self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
if ([self isEnabled] == NO)
|
||||
return;
|
||||
|
||||
// Unbordered color wells start a drag immediately upon mouse down
|
||||
if ([self isBordered] == NO)
|
||||
{
|
||||
[NSColorPanel dragColor: _the_color
|
||||
withEvent: theEvent
|
||||
fromView: self];
|
||||
return;
|
||||
}
|
||||
|
||||
_mouseDownPoint = [self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
[[self cell] setHighlighted: YES];
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
|
||||
- (void) mouseDragged: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint point = [self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
BOOL inside = [self mouse: point inRect: [self bounds]];
|
||||
BOOL startedInWell = [self mouse: _mouseDownPoint inRect: _wellRect];
|
||||
|
||||
if ([self isEnabled] == NO)
|
||||
return;
|
||||
|
||||
if (startedInWell)
|
||||
{
|
||||
[[self cell] setHighlighted: NO];
|
||||
[self setNeedsDisplay: YES];
|
||||
|
||||
[NSColorPanel dragColor: _the_color
|
||||
withEvent: theEvent
|
||||
fromView: self];
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
[[self cell] setHighlighted: inside];
|
||||
[self setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) mouseUp: (NSEvent *)theEvent
|
||||
{
|
||||
NSPoint point = [self convertPoint: [theEvent locationInWindow]
|
||||
fromView: nil];
|
||||
BOOL inside = [self mouse: point inRect: [self bounds]];
|
||||
|
||||
if ([self isEnabled] == NO)
|
||||
return;
|
||||
|
||||
[[self cell] setHighlighted: NO];
|
||||
[self setNeedsDisplay: YES];
|
||||
|
||||
if (inside)
|
||||
{
|
||||
if (_is_active == NO)
|
||||
{
|
||||
[self activate: YES];
|
||||
|
@ -306,19 +361,6 @@ static NSPoint _lastMouseDownPoint;
|
|||
}
|
||||
}
|
||||
|
||||
- (void) mouseDragged: (NSEvent *)theEvent
|
||||
{
|
||||
if ([self isEnabled])
|
||||
{
|
||||
if ([self mouse: _lastMouseDownPoint inRect: _wellRect])
|
||||
{
|
||||
[NSColorPanel dragColor: _the_color
|
||||
withEvent: theEvent
|
||||
fromView: self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id <NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue