Dropping coloured text on a field

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 38
Joined: Sun Nov 15, 2009 11:45 pm
Contact:

Dropping coloured text on a field

Post by andyH »

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
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10507
Joined: Wed May 06, 2009 2:28 pm

Re: Dropping coloured text on a field

Post by dunbarx »

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
andyH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 38
Joined: Sun Nov 15, 2009 11:45 pm
Contact:

Re: Dropping coloured text on a field

Post by andyH »

Thanks for advice. Tried "html" does not work. Only responds to "text" and "rtf" variants.

Maybe I am missing something that is obvious?
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10507
Joined: Wed May 06, 2009 2:28 pm

Re: Dropping coloured text on a field

Post by dunbarx »

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
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10427
Joined: Fri Feb 19, 2010 10:17 am

Re: Dropping coloured text on a field

Post by richmond62 »

I have a feeling the chap means dragging text from outwith Livecode
into a Livecode textField.
andyH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 38
Joined: Sun Nov 15, 2009 11:45 pm
Contact:

Re: Dropping coloured text on a field

Post by andyH »

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
PBH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 135
Joined: Sun Feb 20, 2011 4:26 pm
Contact:

Re: Dropping coloured text on a field

Post by PBH »

Andy,

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
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
andyH
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 38
Joined: Sun Nov 15, 2009 11:45 pm
Contact:

Re: Dropping coloured text on a field

Post by andyH »

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
Post Reply