Revision: 18275
          http://bibdesk.svn.sourceforge.net/bibdesk/?rev=18275&view=rev
Author:   hofman
Date:     2011-12-03 10:58:18 +0000 (Sat, 03 Dec 2011)
Log Message:
-----------
move dragging of icon from text field to BDSKAddressTextField implementation

Modified Paths:
--------------
    trunk/bibdesk/BDSKAddressTextField.m
    trunk/bibdesk/BDSKDragTextField.m

Modified: trunk/bibdesk/BDSKAddressTextField.m
===================================================================
--- trunk/bibdesk/BDSKAddressTextField.m        2011-12-03 07:35:04 UTC (rev 
18274)
+++ trunk/bibdesk/BDSKAddressTextField.m        2011-12-03 10:58:18 UTC (rev 
18275)
@@ -147,6 +147,47 @@
     [super viewDidMoveToWindow];
 }
 
+- (void)mouseDown:(NSEvent *)theEvent {
+    if ([[self delegate] 
respondsToSelector:@selector(dragTextField:writeDataToPasteboard:)]) {
+        NSRect iconRect = [[self cell] iconRectForBounds:[self bounds]];
+        NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
+        if (NSMouseInRect(mouseLoc, iconRect, [self isFlipped])) {
+            NSEvent *nextEvent = [[self window] nextEventMatchingMask: 
NSLeftMouseUpMask | NSLeftMouseDraggedMask];
+            
+            if (NSLeftMouseDragged == [nextEvent type]) {
+                NSPasteboard *pboard = [NSPasteboard 
pasteboardWithName:NSDragPboard];
+                
+                if ([[self delegate] dragTextField:self 
writeDataToPasteboard:pboard]) {
+               
+                    NSImage *dragImage = nil;
+                    NSSize imageSize = NSZeroSize;
+                    NSImage *image = nil;
+                    NSRect drawRect = [self bounds];
+                    NSRect rect = [[self cell] iconRectForBounds:drawRect];
+                    NSPoint dragPoint = rect.origin;
+                    if ([self isFlipped])
+                        dragPoint.y += NSHeight(rect);
+                    drawRect.origin.x -= NSMinX(rect);
+                    drawRect.origin.y -= NSMinY(rect);
+                    image = [[NSImage alloc] initWithSize:rect.size];
+                    [image lockFocus];
+                    [[self cell] drawInteriorWithFrame:drawRect inView:nil];
+                    [image unlockFocus];
+                    imageSize = [image size];
+                    dragImage = [[[NSImage alloc] initWithSize:imageSize] 
autorelease];
+                    [dragImage lockFocus];
+                    [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect 
operation:NSCompositeCopy fraction:0.7];
+                    [dragImage unlockFocus];
+                    [image release];
+                    [self dragImage:dragImage at:dragPoint offset:NSZeroSize 
event:theEvent pasteboard:pboard source:self slideBack:YES]; 
+                }
+            }
+            return;
+        }
+    }
+    [super mouseDown:theEvent];
+}
+
 @end
 
 

Modified: trunk/bibdesk/BDSKDragTextField.m
===================================================================
--- trunk/bibdesk/BDSKDragTextField.m   2011-12-03 07:35:04 UTC (rev 18274)
+++ trunk/bibdesk/BDSKDragTextField.m   2011-12-03 10:58:18 UTC (rev 18275)
@@ -81,47 +81,6 @@
     return [super setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
 }
 
-- (void)mouseDown:(NSEvent *)theEvent {
-    if ([[self cell] respondsToSelector:@selector(iconRectForBounds:)] && 
[[self delegate] 
respondsToSelector:@selector(dragTextField:writeDataToPasteboard:)]) {
-        NSRect iconRect = [[self cell] iconRectForBounds:[self bounds]];
-        NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] 
fromView:nil];
-        if (NSMouseInRect(mouseLoc, iconRect, [self isFlipped])) {
-            NSEvent *nextEvent = [[self window] nextEventMatchingMask: 
NSLeftMouseUpMask | NSLeftMouseDraggedMask];
-            
-            if (NSLeftMouseDragged == [nextEvent type]) {
-                NSPasteboard *pboard = [NSPasteboard 
pasteboardWithName:NSDragPboard];
-                
-                if ([[self delegate] dragTextField:self 
writeDataToPasteboard:pboard]) {
-               
-                    NSImage *dragImage = nil;
-                    NSSize imageSize = NSZeroSize;
-                    NSImage *image = nil;
-                    NSRect drawRect = [self bounds];
-                    NSRect rect = [[self cell] iconRectForBounds:drawRect];
-                    NSPoint dragPoint = rect.origin;
-                    if ([self isFlipped])
-                        dragPoint.y += NSHeight(rect);
-                    drawRect.origin.x -= NSMinX(rect);
-                    drawRect.origin.y -= NSMinY(rect);
-                    image = [[NSImage alloc] initWithSize:rect.size];
-                    [image lockFocus];
-                    [[self cell] drawInteriorWithFrame:drawRect inView:nil];
-                    [image unlockFocus];
-                    imageSize = [image size];
-                    dragImage = [[[NSImage alloc] initWithSize:imageSize] 
autorelease];
-                    [dragImage lockFocus];
-                    [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect 
operation:NSCompositeCopy fraction:0.7];
-                    [dragImage unlockFocus];
-                    [image release];
-                    [self dragImage:dragImage at:dragPoint offset:NSZeroSize 
event:theEvent pasteboard:pboard source:self slideBack:YES]; 
-                }
-            }
-            return;
-        }
-    }
-    [super mouseDown:theEvent];
-}
-
 // flag changes during a drag are not forwarded to the application, so we fix 
that at the end of the drag
 - (void)draggedImage:(NSImage *)anImage endedAt:(NSPoint)aPoint 
operation:(NSDragOperation)operation{
     [[NSNotificationCenter defaultCenter] 
postNotificationName:BDSKFlagsChangedNotification object:NSApp];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to