[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Selecting text in NSTextView
From: |
Fred Kiefer |
Subject: |
Re: Selecting text in NSTextView |
Date: |
Wed, 28 Mar 2007 11:40:13 +0200 |
User-agent: |
Thunderbird 1.5.0.10 (X11/20060911) |
Andreas Höschler wrote:
> can anybody confirm that selecting the empty row between e.g.
>
> #import "hello.h"
>
> #import "beyer.h"
>
> in a NSTextView with a tripleclick does not work under GNUstep? On my
> machine either the top or the bottom non-zero-length line is selected,
> but not the line in the middle. This behaviour is wrong! Any idea?
>
I would expect this behaviour to be caused by the implementation of
[NSTextView selectLine:], which uses [NSLayoutManager
characterIndexMoving:fromCharacterIndex:originalCharacterIndex:] to do
the actual work.
But the solution may even be simpler. When you click on the empty line
the cursor is not set to this line but to the next. I would expect that
as soon as this is corrected the rest will work. So have a look at
[NSText mouseDown:] and characterIndexForPoint: first. It may well be
that for empty lines we always have a fraction of > 0.5 and because of
that end up in the next line. Thinking about it this sounds rather
plausible. So [NSLayoutManager
glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:] may
be the key to your problem.
Cheers,
Fred