Drag and Drop Text into a field

Pete pete at mollysrevenge.com
Mon Sep 26 14:37:36 EDT 2011


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>



More information about the use-livecode mailing list