Drag and Drop Text into a field

Peter M. Brigham, MD pmbrig at gmail.com
Mon Sep 26 16:01:59 EDT 2011


You could set a customprop of the field control on mouseleave:

on mouseleave
   set the uSelChunk of me to the selectedchunk
end mouseleave

then in your dragdrop handler:

put the uSelChunk of fld "targetField" into selCh
put word 2 of selCh into startChar
put word 4 of selCh into endChar
put the clipboardData["text"] into char startChar to endChar of fld "targetField"

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


On Sep 26, 2011, at 2:37 PM, Pete wrote:

> I'm trying to find a way to drag and drop text from a datagrid into a field
> control.  If no text is selected in the field control, the text should be
> inserted at the insertion point; if text is selected, the dragged text
> should replace the selected text.
> 
> The way I'm doing this is:
> 
> - The dragStart handler for the datagrid places the text I want to insert
> into the clipboardData["text"]
> - The dragEnter handler for the field control sets the focus on the field
> control
> - The dragDrop handler for the field control issues a paste command
> 
> That all works fine when no text is selected in the field control, LC
> appears to remember where the insertion is in the field control.  However,
> let's say I select some text in the field control.  As soon as I click on a
> line in the datagrid to start the drag/drop operation, the text is no longer
> selected in the field control and when I drop the text into the field
> control it is inserted at what was the end point of the text I had
> originally selected.
> 
> To illustrate, if the field control contains "This is my Text" and I select
> the word "my", then drag the text "your" to the field Control, it will be
> inserted right after "my" instead of replacing it.
> 
> Am I setting about this the wrong way or can this approach be made to work
> somehow?
> 
> Thanks,
> 
> Pete
> Molly's Revenge <http://www.mollysrevenge.com>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list