Hi,
Here is a patch which makes NSColorWell activate when you click in the
coloured rectangle, matching OS X's behaviour. Dragging from the
coloured area works the same as before.

The current behaviour, where clicking in the coloured rectangle starts
and then immediately cancels a drag operation doesn't make sense to me
(and there has been an inquiry sent to the mailing list from someone
who thought colour wells were broken - they didn't realise you had to
click on the border).

Regards,
Eric
Index: Source/NSColorWell.m
===================================================================
--- Source/NSColorWell.m	(revision 29096)
+++ Source/NSColorWell.m	(working copy)
@@ -46,6 +46,8 @@
 static NSString *GSColorWellDidBecomeExclusiveNotification =
                     @"GSColorWellDidBecomeExclusiveNotification";
 
+static NSPoint _lastMouseDownPoint;
+
 @implementation NSColorWell
 
 /*
@@ -289,17 +291,12 @@
   //
   if ([self isEnabled])
     {
-      NSPoint point = [self convertPoint: [theEvent locationInWindow]
-                            fromView: nil];
+      _lastMouseDownPoint = 
+         [self convertPoint: [theEvent locationInWindow]
+                   fromView: nil];
 
-      if ([self mouse: point inRect: _wellRect])
+      if (_is_active == NO)
 	{
-	  [NSColorPanel dragColor: _the_color
-			withEvent: theEvent
-			fromView: self];
-	}
-      else if (_is_active == NO)
-	{
 	  [self activate: YES];
 	}
       else
@@ -309,6 +306,19 @@
     }
 }
 
+- (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];
_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to