classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] RFC: Suggested change in PlainView.


From: Roman Kennke
Subject: Re: [cp-patches] RFC: Suggested change in PlainView.
Date: Thu, 03 Nov 2005 23:22:59 +0000

Hi there,

Am 3.11.2005 schrieb "Roman Kennke" <address@hidden>:

>Hi Audrius,
>
>Am Donnerstag, den 03.11.2005, 15:50 +0100 schrieb Meskauskas Audrius:
>> Our JTextField contains an "imaginary" end of line character (0xA), but 
>> the new text must be always inserted before it, not after. When clicking 
>> right from the last character in the field, the 
>> PlainTextView.viewToModel should return the position before the end of 
>> line character and not after the end of line character. Otherwise the 
>> inputs blocks. If the empty field receives focus by the mouse click, the 
>> caret position is always set after the 0xA and, a result, it is never 
>> possible to enter any text in the field.
>
>Wow, good observations and bug finding. You are right, the Content model
>of the PlainDocument contains an imaginary 0xA character at the end.
>This should not be exposed via the Document accessor methods, also not
>by the viewToModel or getText. Your patch fixes you problem, but at best
>hides the real problem, beeing that this newline character is somehow
>counted in in getText.
>
>I can fix this tomorrow. Thanks for this good observations.

It looks like your fix was practically correct. I checked the getText()
method and it actually should return the final newline character. I
simplified your patch a little, in PlainView we can assume that every
line ends in a newline (that is possible the whole point of this one
implicit newline) and exclude that from the calculation in viewToModel.

Also I fixed a little error that sneaked in with one of my previous
DefaultCaret patches so caret positioning in JTextFields should now work
again.

2005-11-03  Roman Kennke  <address@hidden>

        * javax/swing/text/DefaultCaret.java
        (positionCaret): Call setDot instead of moveDot.
        * javax/swing/text/PlainView.java
        (viewToModel): Exclude the final newline character from
calculation.

/Roman

Attachment: swing-text-fixes.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]