Drag and Drop

Peter Haworth pete at mollysrevenge.com
Mon Feb 7 20:07:02 EST 2011


OK, I have this working.  Thank you SCott for pointing me to your script.

I had to change Scott's script because his demo creates a destination stack on the fly so he knows it's name, location, etc.  In my case, I needed the user to be able to drop the control onto any currently open stack.  And, as someone else pointed out, the mouseStack property does NOT correctly report the name of the stack that the mouse is over unless you are in a mouseUp handler, or at least it didn't in Scott's handler. Sorry to keep harping on this, but the dictionary, yet again, is flawed.

I found the IDE code that handles the drag and drop of controls from the Tools palette. It figures out which stack the mouse is over by comparing the mouse location to the rectangle of each open stack.  So I did the same thing and it works fine.  I hope I'm not breaking any intellectual property laws.

I'm left with one strangeness.  As a control is being dragged, it has a blue background. After it is copied to the new stack, it still has a blue background until I click on it, then it goes back to the background of the original control.  I noticed that happening in Scott's script (except it's green instead of blue).  Not a big deal but Scott, wondering if you might have a fix for that?

Pete Haworth

On Feb 6, 2011, at 9:55 PM, Scott Rossi wrote:

> Pete:
> 
> There are several drag and drop references you can explore (for example, the
> LiveCode User Guide found under Help > User Guide, page 262).  LC has all
> the commands to implement what you want.
> 
> On a semi-related note, I have a drag and drop sample stack that is all
> LiveCode script, based on work done by the late Eric Chatonet.  I wanted a
> drag and drop routine that represented dragged objects using their original
> forms, rather than a rectangle.  You can get the stack by executing the
> following in your message box:
> go url "http://www.tactilemedia.com/site_files/downloads/TMdragndrop.rev"
> 
> Start dragging any object and the "drop stack" will open automatically.
> Note that this doesn't use LC's drag and drop routines, and as such has a
> couple of limitations, so learning the "real" drag and drop routines might
> be better in the long run.  But the scripted solution works fine for me.  As
> they say, YMMV.
> 
> Regards,
> 
> Scott Rossi
> Creative Director
> Tactile Media, UX Design
> 
> 
> 
> 
> Recently, Peter Haworth wrote:
> 
>> Sounds perfect!  Now if I only knew how to do that.....
>> Pete Haworth
>> 
>> On Feb 6, 2011, at 5:21 PM, DunbarX at aol.com wrote:
>> 
>>> If you know what controls are where, and you must because you made them,
>>> named them and placed them on your palette, then can't you just get target
>>> info, clone the control, and make it track the mouse until dropped?
>>> 
>>> 
>>> Or am I missing everything?
>>> 
>>> 
>>> Craig Newman
>>> 
>>> 
>>> 
>>> 
>>> 
>>> -----Original Message-----
>>> From: Peter Haworth <pete at mollysrevenge.com>
>>> To: How to use LiveCode <use-livecode at lists.runrev.com>
>>> Sent: Sun, Feb 6, 2011 4:16 pm
>>> Subject: Drag and Drop
>>> 
>>> 
>>> I would like to set up the equivalent of the LC Tools palette so I can drag
>>> and 
>>> drop some custom controls from it to any card.
>>> 
>>> Mark - I read your excellent write up on Drag and Drop but it seems to be
>>> aimed 
>>> at a different situation than this (dragging info from one control to
>>> another).  
>>> I also used the message watcher to see what happens when I drag an LC control
>>> from the LC tools palette to a card and I didn;t see any of the standard
>>> drag/drop messages.
>>> 
>>> Any tips on how to set about doing this?
>>> 
>>> Pete Haworth
>>> 
> 
> 
> 
> _______________________________________________
> 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