Drag and Drop from Palette Window

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
Hutchboy
Posts: 111
Joined: Wed Aug 01, 2018 2:57 pm
Contact:

Drag and Drop from Palette Window

Post by Hutchboy » Thu Apr 16, 2020 7:36 pm

Hi, I have been looking for ways to emulate the behavior of the IDE tool palette, where you can drag and drop a control onto your stack. I am not looking for code examples, just a general approach to how it is done. When I peruse the revTools stack script, there is a lot going on there I appreciate but just barely follow. However, I have gleaned a few things and want to know if I'm on the right track:

PseudoCode

Check if mouse is down in your Palette stack over a control
Allow for some threshold movement tracking when the mouse enters a control
Create a temporary stack with a window shape that is derived from the control shape
Optionally, set the blend level of the the temp stack while it is being dragged (if you want it to be "ghosted" during drag)
If the mouse is released while the temp stack is in the window of the main stack, then delete the temp stack that is being dragged and...
Lastly, create the new control at the location where the mouse is released.

One of my favorite early hypercard stacks was PippinPuss. I have recreated it in LiveCode completely, but would like to move the grid of face components into a palette...hence my question.

Klaus
Posts: 14192
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Drag and Drop from Palette Window

Post by Klaus » Thu Apr 16, 2020 7:55 pm

Hi Hutchboy,

not sure what your question is, if at all, but LC does not use a temp stack, but the build-in feature -> the dragimage
And all the buttons in the TOOLS palette have a dragstart handler (resp. a behavior).

Read up all the DRAGxxx commands and functions in the dictionary to get an idea of what LC is doing behind the scenes.
Remember: LC ist completely programmed in LC! :D


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Drag and Drop from Palette Window

Post by dunbarx » Thu Apr 16, 2020 8:22 pm

Hi.

Your pseudoCode is basically sound. But why a temporary stack? Why not just clone the control of interest? All the other gadgetry, the ghost image, etc., can work just fine on that control. And then you do no need to "know" what kind of control you are dealing with; it is already in hand.

Craig

Hutchboy
Posts: 111
Joined: Wed Aug 01, 2018 2:57 pm
Contact:

Re: Drag and Drop from Palette Window

Post by Hutchboy » Thu Apr 16, 2020 10:05 pm

Thanks for the feedback. I have no problem cloning and dragging buttons, images or groups within my main stack window, or even clicking on a control in my palette stack and having it appear in my main stack, I just couldn't figure out how to drag a visible image from a palette sub stack across to my main window. I'll follow your advice and explore your suggestions.

BTW, the rather long mousedown handler in the revTools stack clearly is creating a drag stack (it's in the commented source code). I thought maybe this was the only way to have an image move across the desktop from one stack window to another stack window. I am kind of new to exploring the IDE stack scripts, so maybe I'm just misunderstanding what this mousedown handler is doing.

I have searched for any example but haven't seen any that simulate the IDE tool palette. If anyone could point me to an example I would appreciate it.

Thanks and stay safe.

Post Reply