Invalid caret position

General TRichView support forum. Please post your questions here
Post Reply
Cat
Posts: 4
Joined: Wed Jul 01, 2015 4:16 am

Invalid caret position

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Cat
Posts: 4
Joined: Wed Jul 01, 2015 4:16 am

Post by Cat »

Which event should I use then?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please describe what do you want to implement, I'll try to suggest how to do it.
Cat
Posts: 4
Joined: Wed Jul 01, 2015 4:16 am

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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)
Cat
Posts: 4
Joined: Wed Jul 01, 2015 4:16 am

Post by Cat »

Sadly in onChange I don't know what item exactly was changed. But thanks anyway.
Post Reply