[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Doubleclicking NSTextView
From: |
Andreas Höschler |
Subject: |
Re: Doubleclicking NSTextView |
Date: |
Fri, 31 Aug 2007 17:15:03 +0200 |
Hi all,
on MacOSX one can select an empty line by double-clicking on it. You
can also select the contents (select all) of an NSTextField by
doubleclicking on the space behind the (short) string.
-- doubleclick here - -
\/
-------------------------------------------
dog |
-------------------------------------------
Under GNUstep you have to hit the string otherwise it does not work.
Selecting empty lines by doubleclicking is not possible at all under
GNUstep. I will look into this later today, but since this is so
annoying I suppose somebody has already tried to take care of this
(and failed)!? :-( Is this a greater problem with the current
NSTextView architecture?
I fixed this issue as follows, making NSTextView behave close to what
we have on a Mac. :-)
- (void)mouseDown:(NSEvent *)theEvent
{
...
if (!_layoutManager)
return;
/* Otherwise, NSWindow has already made us first responder (if
possible) */
startPoint = [self convertPoint:[theEvent locationInWindow]
fromView:nil];
startIndex = [self characterIndexForPoint:startPoint];
+ if (startIndex != (unsigned)-1 && startIndex > 0)
+ {
+ NSString *string = [self string];
+ if ([string characterAtIndex:startIndex - 1] == '\n')
startIndex--;
+ }
if (startIndex == (unsigned int)-1)
{
return;
}
...
}
- (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange
granularity:(NSSelectionGranularity)gr
{
...
if (proposedCharRange.location >= length)
{
proposedCharRange.location = length;
proposedCharRange.length = 0;
+ switch (gr)
+ {
+ case NSSelectByCharacter:
+ break;
+ default:
+ return [string lineRangeForRange:proposedCharRange];
+ break;
+ }
return proposedCharRange;
}
...
)
Regards,
Andreas