Page 1 of 1

Invalid caret position

Posted: Wed Jul 01, 2015 4:30 am
by Cat
Hello, I have a bug with Text Items. When I try delete text in text items I got an error: "Invalid caret position. Please contact the developer, if you can reproduce this problem." And I can reproduce this. :) Minimal application for reproduce, https://www.dropbox.com/s/l3zdwz2zcjwxcng/SRV1.zip?dl=0
First of all write something in first item, then go to the end of the first item and press backspace. That's all you got an error.

Posted: Wed Jul 01, 2015 7:59 am
by Sergey Tkachenko
It's not allowed to modify text or to make any other changes in document inside OnItemTextEdit event. This event is designed for modifying tag and style (by assigning new values to the parameters) depending on changes in text.

Posted: Wed Jul 01, 2015 8:56 am
by Cat
Which event should I use then?

Posted: Wed Jul 01, 2015 2:50 pm
by Sergey Tkachenko
Please describe what do you want to implement, I'll try to suggest how to do it.

Posted: Thu Jul 02, 2015 7:09 am
by Cat
I want to when I change the text in first item, it changes in second item at the same time. Like in my example app.

Posted: Thu Jul 02, 2015 7:15 am
by Sergey Tkachenko
In OnChange, check GetItemText. If it was changed, use SetItemTextEd to modify the second item (set some boolean flag while calling SetItemTextEd to prevent infinite recursion, because SetItemTextEd calls OnChange too)

Posted: Thu Jul 02, 2015 12:35 pm
by Cat
Sadly in onChange I don't know what item exactly was changed. But thanks anyway.