Message-ID: <30097@apple.UUCP>
Date: Fri, 8-Mar-85 22:14:46 EST
Article-I.D.: apple.30097
Posted: Fri Mar 8 22:14:46 1985
Date-Received: Mon, 11-Mar-85 04:49:16 EST
References:
Reply-To: lsr@apple.UUCP (Larry Rosenstein)
Organization: Macintosh Division, Apple Computer
Lines: 50
Summary:
In article ee163ahe@sdcc13.UUCP (VICTOR ROMANO) writes:
>
>
>
> There is an interesting bug in TESetSelect. If it is called before
> TEClick is ever called, the selection region is set to the proper
> value, but the caret appears at the end of the previous line if
> it was intended to appear at the beginning of a line.
TextEdit represents its selections by the character positions; if the start
and end character positions are the same then you have an insertion point.
If the character after the insertion point is at the start of the line, it
is ambiguous whether the caret should be displayed at the start of the line
or the END of the PREVIOUS line. (Either is plausible in certain
situations.)
That is where the clikStuff comes in. The INTEGER is really used as 2
booleans; the first could be called TELeftClick and the second TELeftCaret.
TEClick uses a utility routine to determine what character the mouse was
clicked on. That utility returns a character position, but the mouse could
have been to the left or right of the center of the character, and it makes
a difference as to where the insertion point goes. So the utility sets
TELeftClick to indicate if the click was on the left side of the character.
TEClick copies TELeftClick into TELeftCaret.
When it comes time to draw the caret we have the ambiguity mentioned above
if the insertion point is before a character at the start of a line.
The value of TELeftCaret resolves the ambiguity.
I wouldn't call this a bug, only a lack of documentation. The same problem
can arise even after TEClick was called once, if the last click was on the
right side of a character. Also, the fix that was given before forces the
caret to be at the start of the line, rather than the end of the previous
line, which might not be what you want.
The moral of the story is that before you use TESetSelect to set an
insertion point, and you suspect that the insertion point will be at the
start of a line/end of a line, then you should set the clikStuff field to
-1 if you want the caret at the start of the line and 0 if you want it at
the end of the previous line.
(Unlike what was implied in the original message, there should be no
problem with other TE routines if you choose one or the other.)
--
Larry Rosenstein
UUCP: {nsc, dual, voder, ios}!apple!lsr
CSNET: lsr@Apple.CSNET