From d63c81bdea074598b44c976775b90a7ef027d1bf Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Mon, 4 Jun 2001 16:25:32 +0000 Subject: [PATCH] Implemented some basic handling for mouse down on attachment cell. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10072 72102866-910b-0410-8b05-ffd578937521 --- Source/NSTextView.m | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Source/NSTextView.m b/Source/NSTextView.m index 1e5da2732..7160ee5b5 100644 --- a/Source/NSTextView.m +++ b/Source/NSTextView.m @@ -2036,14 +2036,43 @@ afterString in order over charRange. */ possible) */ startPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil]; - + startIndex = [self characterIndexForPoint: startPoint]; + + if (_tf.imports_graphics == YES) + { + NSTextAttachment *attachment; + + // Check if the click was on an attachment cell + attachment = [_textStorage attribute: NSAttachmentAttributeName + atIndex: startIndex + effectiveRange: NULL]; + + if (attachment != nil) + { + id cell = [attachment attachmentCell]; + // FIXME: Where to get the cellFrame? + NSRect cellFrame = NSMakeRect(0, 0, 0, 0); + + if ((cell != nil) && + ([cell wantsToTrackMouseForEvent: theEvent + inRect: cellFrame + ofView: self + atCharacterIndex: startIndex] == YES) && + ([cell trackMouse: theEvent + inRect: cellFrame + ofView: self + atCharacterIndex: startIndex + untilMouseUp: NO] == YES)) + return; + } + } + if ([theEvent modifierFlags] & NSShiftKeyMask) { /* Shift-click is for extending an existing selection using the existing granularity */ granularity = _selectionGranularity; /* Compute the new selection */ - startIndex = [self characterIndexForPoint: startPoint]; proposedRange = NSMakeRange (startIndex, 0); proposedRange = NSUnionRange (_selected_range, proposedRange); proposedRange = [self selectionRangeForProposedRange: proposedRange @@ -2072,7 +2101,6 @@ afterString in order over charRange. */ case 3: granularity = NSSelectByParagraph; break; } - startIndex = [self characterIndexForPoint: startPoint]; proposedRange = NSMakeRange (startIndex, 0); }