Copy link to clipboard
Copied
Hi,
Is there some quick way to clone a data structure, like a text range, rather than doing all this:
newTR = new TextRange();
newTR.beg.obj = oldTR.beg.obj;
newTR.beg.offset = oldTR.beg.offset;
newTR.end.obj = oldTR.end.obj;
newTR.end.offset = oldTR.end.offset;
I tried this, but it failed as I expected:
newTR = oldTR.clone();
I tried this, but I got back the same object:
newTR = new TextRange(oldTR.beg, oldTR.end);
Any ideas?
Thanks,
Russ
Copy link to clipboard
Copied
Hi Russ,
A little late in responding, and not much to help you forward, I'm afraid. The TextRange object seems to merely contain pointers to its objects, rather than copies of the objects themselves. I have run into problems even setting the offset of the beg and end objects separately without first creating two new objects for them explicitly. Strange animals, those TextRanges.
Ciao
Jang