Copy text between fields preserving formatting
Posted: Sat Dec 14, 2013 8:28 pm
Hi,
Whilst I continue to struggle with Android I have been trying to come up with a generic (cross platform - hence I'm not using the 'clipboard') method / script to copy and paste text between two html fields.
In my scenario a user may have entered some quite detailed 'standard' text in one record and want to have it duplicated to another (generally, new) record.
I currently have buttons to make a users selected text bold, italic, underlined & coloured etc and other buttons enabling certain standard data to be inserted at the cursor position (such as the date etc.). All this works great.
My problem comes when I try to copy html formatted text from one field to another html formatted field. I always end up with either no formatting for my inserted / copied text (more precisely, inserted text that inherits the text formatting around its insert position) or the verbose html (< b>My < i>copied text< /i>< /b> type of thing).
I've tried playing with [1] just inserting the variable contents (gsMyCopiedText) into the new location, [2] putting my copied text into another field (as htmltext - which displays the formatting correctly in this other, temporary field) BUT I cannot for the life of me put formatted text into a specific (cursor) location in an existing formatted field without (like I say) it either losing its formatting or it displaying the html format tags...
I've have tried using 'selectedchunk' to get me the start / stop positions of the highlighted position within the new field that the copied text is to go into and also 'put 'gs'MyCopiedText'...into the selection' to try and sort this out but whatever I do I make no progress... and I'm now going round in circles !
I've also googled and searched the forums for an answer without success...
Is this normal behaviour (I can copy and paste into a specific location - but lose any html formatting) or is there something I'm missing please ?
Thanks.
Whilst I continue to struggle with Android I have been trying to come up with a generic (cross platform - hence I'm not using the 'clipboard') method / script to copy and paste text between two html fields.
In my scenario a user may have entered some quite detailed 'standard' text in one record and want to have it duplicated to another (generally, new) record.
I currently have buttons to make a users selected text bold, italic, underlined & coloured etc and other buttons enabling certain standard data to be inserted at the cursor position (such as the date etc.). All this works great.

My problem comes when I try to copy html formatted text from one field to another html formatted field. I always end up with either no formatting for my inserted / copied text (more precisely, inserted text that inherits the text formatting around its insert position) or the verbose html (< b>My < i>copied text< /i>< /b> type of thing).
I've tried playing with [1] just inserting the variable contents (gsMyCopiedText) into the new location, [2] putting my copied text into another field (as htmltext - which displays the formatting correctly in this other, temporary field) BUT I cannot for the life of me put formatted text into a specific (cursor) location in an existing formatted field without (like I say) it either losing its formatting or it displaying the html format tags...
I've have tried using 'selectedchunk' to get me the start / stop positions of the highlighted position within the new field that the copied text is to go into and also 'put 'gs'MyCopiedText'...into the selection' to try and sort this out but whatever I do I make no progress... and I'm now going round in circles !

Is this normal behaviour (I can copy and paste into a specific location - but lose any html formatting) or is there something I'm missing please ?
Thanks.