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
Location: Glasgow, United Kingdom
Contact:

Dropping coloured text on a field

Post by andyH » Fri Jul 18, 2014 6:51 pm

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: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Dropping coloured text on a field

Post by dunbarx » Sun Jul 20, 2014 1:58 am

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
Location: Glasgow, United Kingdom
Contact:

Re: Dropping coloured text on a field

Post by andyH » Sun Jul 20, 2014 5:25 am

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: 9669
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Dropping coloured text on a field

Post by dunbarx » Sun Jul 20, 2014 4:14 pm

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: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Dropping coloured text on a field

Post by richmond62 » Sun Jul 20, 2014 4:26 pm

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
Location: Glasgow, United Kingdom
Contact:

Re: Dropping coloured text on a field

Post by andyH » Sun Jul 20, 2014 6:13 pm

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: 129
Joined: Sun Feb 20, 2011 4:26 pm
Location: Vancouver Island, BC, Canada. ex.UK
Contact:

Re: Dropping coloured text on a field

Post by PBH » Mon Jul 21, 2014 1:58 am

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
Location: Glasgow, United Kingdom
Contact:

Re: Dropping coloured text on a field

Post by andyH » Mon Jul 21, 2014 10:19 am

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

Return to “Getting Started with LiveCode - Experienced Developers”