R3. SelectionStart being moved

desktop. I am having a problem with TextArea’s SelectionStart being moved after it’s set in code on R3. I have a custom event handler called OnPaste which sets a Boolean which blocks funny things like moving the insertion point.
I know it goes into and out of, by code, TextChanged, because of the boolean.
I also have a small project which uses the event and it doesn’t happen there.

Any suggestions?

I filed a bug report.
[feedback://showreport?report_id=66854](https://66854 - SelectionStart get moved to 0 caused by project scale)

Your example dont even runs. And it is not simple. Perfect combination to be ignored by the staff :expressionless:

Well, just replaced all the code in the OnPaste even for something simple:

Var c As New Clipboard
Var selStrt As Integer
Var tstr As String = c.Text
If tstr.IsEmpty Then Return

c.Text = c.Text.Trim
selStrt = Me.SelectionStart + c.Text.Length

Me.SelectionStart = selStrt-5

And the SelectionStart set by code works ok. Moves the cursor 5 character before the end of the pasted text. Something else in your code is moving it to the beginning. :thinking:

Thank you. You are quite correct in that is not simple. If it is simple the bug doesn’t appear.

When I looked at SelectionStart in the debugger before the paste I get eg. 200

After that I add to 200 the length of the text, and the debugger reports what it should be at the VERY end of the event. It doesn’t go anywhere unusual after that including places where SelectionStart is reset to 0.

If anyone wants to check out my project here it is in a a folder with a couple of files.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.