textArea.selStart firing scrollPosition

win32: I have a textarea filled with text, the insertion point is set at the beginning of the text.
Now, setting for instance
textarea1.selStart = 1300 (or any other value)
the first line of the text jumps to selStart as if I had called scrollPosition.
Since textarea1.selStart is part of a tight routine to colorize some words, I cannot reasonably reset the scrollPosition to zero every time selStart is called.
On the other end, on the Mac, the position of the text remains unaltered.

Suggestions welcome. Thanks.

[quote=204805:@Carlo Rubini]win32: I have a textarea filled with text, the insertion point is set at the beginning of the text.
Now, setting for instance
textarea1.selStart = 1300 (or any other value)
the first line of the text jumps to selStart as if I had called scrollPosition.
Since textarea1.selStart is part of a tight routine to colorize some words, I cannot reasonably reset the scrollPosition to zero every time selStart is called.
On the other end, on the Mac, the position of the text remains unaltered.[/quote]

If the SelStart position is not visible, then it seems logical to show it to the user, so the TextArea scrolls to that position.

The workaround to do your coloring discreetly is to save the current SelStart, disable the TA, modify Selstart and do your coloring, the restore the previous SelStart and enable back the TextArea.

dim oldSelStart as integer = TextArea1.SelStart TextArea1.enabled = False textarea1.selStart = 1400 // Do the coloring and stuff TextArea1.SelStart = oldSelStart TextArea1.enabled = True TextArea1.Setfocus

Already tried setting Textarea1.enabled = false; no coloring happens.

Indeed. Then use Visible. It colors text quite fine and the scrolling is hidden the same way.

Since the text to be parsed can be huge, making the field not visible leaves the window bare too long.
I think I will resort either to put up an alert window (“Parsing text”) that closes at the end of the process, or to do the job in an invisible field and then paste its content to the “real” field.

Here is something I just tested :

  • Make your TextArea1 a control set
  • Add T as TextArea to the window

[code] T = new TextArea1

dim oldSelStart as integer = TextArea1(0).SelStart

// Do the coloring and stuff
textarea1(0).selStart = 1400
textarea1(0).SelLength = 100
textarea1(0).SelTextColor = &cFF008000

TextArea1(0).SelStart = oldSelStart
TextArea1(0).Setfocus

T.close[/code]

That way the T clone covers the TextArea while you do all your coloring. If it does take longer than half a second, you may want to make T read only to avoid undue text manipulation during the process.