Dropping coloured text on a field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- VIP Livecode Opensource Backer
- Posts: 38
- Joined: Sun Nov 15, 2009 11:45 pm
- Location: Glasgow, United Kingdom
- Contact:
Dropping coloured text on a field
If I copy and paste text from another application or pdf onto a field then I retain the colour information for the text.
If I drag and drop the same text, it does not retain the colour information.
Using on dragDrop handler within the field.
using code like
on dragDrop
if "text" is in keys(the dragData) then
put the dragData after me
end if
pass dragDrop
end dragDrop
Any ideas?
Thanks
Andy
If I drag and drop the same text, it does not retain the colour information.
Using on dragDrop handler within the field.
using code like
on dragDrop
if "text" is in keys(the dragData) then
put the dragData after me
end if
pass dragDrop
end dragDrop
Any ideas?
Thanks
Andy
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Dropping coloured text on a field
Hi,
Check the dictionary under "dragData". Similarly to the "clipBoardData", you may specify the nature of the dragged text. In this case, again similarly to the clipBoard, try the "html" variant.
Craig Newman
Check the dictionary under "dragData". Similarly to the "clipBoardData", you may specify the nature of the dragged text. In this case, again similarly to the clipBoard, try the "html" variant.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 38
- Joined: Sun Nov 15, 2009 11:45 pm
- Location: Glasgow, United Kingdom
- Contact:
Re: Dropping coloured text on a field
Thanks for advice. Tried "html" does not work. Only responds to "text" and "rtf" variants.
Maybe I am missing something that is obvious?
Maybe I am missing something that is obvious?
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Dropping coloured text on a field
Hi.
You know, I just replied with what I thought I knew. It turns out I do not know what you mean in your post.
If I place some styled and colored text in a field, whether pasted or simply typed, and drag it either to another part of that field or to another field, all the styles and so forth hold.
Where am I mishandling your point?
Craig
You know, I just replied with what I thought I knew. It turns out I do not know what you mean in your post.
If I place some styled and colored text in a field, whether pasted or simply typed, and drag it either to another part of that field or to another field, all the styles and so forth hold.
Where am I mishandling your point?
Craig
-
- Livecode Opensource Backer
- Posts: 9388
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Dropping coloured text on a field
I have a feeling the chap means dragging text from outwith Livecode
into a Livecode textField.
into a Livecode textField.
-
- VIP Livecode Opensource Backer
- Posts: 38
- Joined: Sun Nov 15, 2009 11:45 pm
- Location: Glasgow, United Kingdom
- Contact:
Re: Dropping coloured text on a field
Hi Richmond62
You are correct. I want to drag that has some words in a different colour from the default black from an external source - such as a pdf, or another application, and drop it into a LiveCode field and retain the colour information.
I also need to do the reverse. Drag the text in a LiveCode field that has some words with a different colour than just black into another application such as Pages and retain the colour information.
If I copy and paste into or out of a LiveCode field then I retain the colour information in those words of the text that are not black.
Thanks for your help.
Andy
You are correct. I want to drag that has some words in a different colour from the default black from an external source - such as a pdf, or another application, and drop it into a LiveCode field and retain the colour information.
I also need to do the reverse. Drag the text in a LiveCode field that has some words with a different colour than just black into another application such as Pages and retain the colour information.
If I copy and paste into or out of a LiveCode field then I retain the colour information in those words of the text that are not black.
Thanks for your help.
Andy
-
- VIP Livecode Opensource Backer
- Posts: 129
- Joined: Sun Feb 20, 2011 4:26 pm
- Location: Vancouver Island, BC, Canada. ex.UK
- Contact:
Re: Dropping coloured text on a field
Andy,
This works for me for dragging coloured text from a PDF into a LC field…
Dragging text out of a LC field to a word processor does carry the coloured text without any extra code as far as I can see.
Paul
This works for me for dragging coloured text from a PDF into a LC field…
Code: Select all
--Field Script
on dragEnter
if the dragData["rtf"] is not empty then
set the dragAction to "copy" -- Shows the drag copy cursor
end if
end dragEnter
on dragDrop
if the dragData["rtf"] is not empty then
set the rtfText of me to the dragData["rtf"]
end if
end dragDrop
Paul
-
- VIP Livecode Opensource Backer
- Posts: 38
- Joined: Sun Nov 15, 2009 11:45 pm
- Location: Glasgow, United Kingdom
- Contact:
Re: Dropping coloured text on a field
Thanks Paul for your solution.
I have adapted it, as I am also dropping in files, and now have the coloured text when I drop it on a field. The only part I have taken out is dropping a text clipping on the desktop as this seemed to interfere with getting the rtfText.
Thanks again for the help.
Andy
I have adapted it, as I am also dropping in files, and now have the coloured text when I drop it on a field. The only part I have taken out is dropping a text clipping on the desktop as this seemed to interfere with getting the rtfText.
Thanks again for the help.
Andy