E
eBob.com
I have a RichTextBox in which users can insert text which they select from a
list. They can also do all other editing actions associated with an RTB.
The problem is, having inserted text from the list they can then decide to
delete it. And I would really like for them to only have to do a right
click on the inserted text and then, when I see that they have clicked on
text inserted from the list, I will add to the context menu an item which
deletes the text. I.E. the user should not have to "select" the text first.
So far as I can tell I will have to maintain an array of offset/lenghts of
instances of inserted text (i.e. inserted from the list of available
strings). But every time the user inserts or deletes text the offsets of
all of the following instances of inserted text will have to be adjusted.
Say the RTB contains "the quick brown fox jumped over the lazy dog"; and
then the user inserted (from the list) "FAT" so that the text is now "the
quick brown fox jumped over the FAT lazy dog". Then maybe the user deletes
"brown". That of course would change the offset of "FAT".
I fear that keeping the array of offset/lengths will get messy. And I am
afraid that I may run into show stopping problems. For example, I have no
idea how to handle cut/paste. Well, no idea that is practical.
So ... is there a better way to keep track of the text inserted from the
list? I do, btw, "protect" the text inserted from the list. But I don't
think that helps because one string of inserted text could be inserted right
after another.
Thanks for any ideas. Bob
list. They can also do all other editing actions associated with an RTB.
The problem is, having inserted text from the list they can then decide to
delete it. And I would really like for them to only have to do a right
click on the inserted text and then, when I see that they have clicked on
text inserted from the list, I will add to the context menu an item which
deletes the text. I.E. the user should not have to "select" the text first.
So far as I can tell I will have to maintain an array of offset/lenghts of
instances of inserted text (i.e. inserted from the list of available
strings). But every time the user inserts or deletes text the offsets of
all of the following instances of inserted text will have to be adjusted.
Say the RTB contains "the quick brown fox jumped over the lazy dog"; and
then the user inserted (from the list) "FAT" so that the text is now "the
quick brown fox jumped over the FAT lazy dog". Then maybe the user deletes
"brown". That of course would change the offset of "FAT".
I fear that keeping the array of offset/lengths will get messy. And I am
afraid that I may run into show stopping problems. For example, I have no
idea how to handle cut/paste. Well, no idea that is practical.
So ... is there a better way to keep track of the text inserted from the
list? I do, btw, "protect" the text inserted from the list. But I don't
think that helps because one string of inserted text could be inserted right
after another.
Thanks for any ideas. Bob