Page 1 of 1

Creating your own tools palate

Posted: Fri Apr 20, 2012 3:30 am
by marksmithhfx
Is it possible to create your own tools palate with fields of your own specification or design that you can then drag onto a card? How would one go about constructing such a thing? How would one make the objects drag and droppable from one card/palate to another?

Thanks

-- Mark

Re: Creating your own tools palate

Posted: Fri Apr 20, 2012 3:58 am
by sturgis
Haven't dug into how they do it, but both Powertools by Mark W and droptools from Sons of thunder do this. Think droptools is free and you can dig through it (maybe?) as well as add your own tools to it. Haven't looked at either for a little bit though so not sure what restrictions there are on either and if yuo can see code but they're both great examples of what you're asking about.

Powertools is here. http://www.ahsoftware.net/PowerTools/

Droptools is here. http://droptools.sonsothunder.com/moreinfo.irev

Re: Creating your own tools palate

Posted: Fri Apr 20, 2012 4:20 am
by dunbarx
This is easy to do. There must be a dozen approaches.

Make a button. Put this into its script:

Code: Select all

on mouseDown
   clone me
   repeat until the mouse is up
   set the loc of the last btn to the mouseLoc
   end repeat
end mouseDown
Now click on the button and hold the mouse down while you drag it away. Can you embellish this so that you are asked to rename it? You can make a palette with all the objects on it and do similar things. Can you do it a different way?

NOTE that the "last" keyword is not stable with groups, if you happen to try to do those. You have to set the templateGroup or use the "newGroup" message. See the dictionary. But all other objects can be referenced with "last".

Craig Newman

Re: Creating your own tools palate

Posted: Fri Apr 20, 2012 8:28 am
by doobox
Hi Craig,

That's the basis of another great way to heighten the user experience.
But how would i go about expanding on this to enable the clone to be dragged out of the bounds of the palette it was created, and dropped into a new card, in the same manner the tools in live-code work..?

I am guessing when you click & drag a tool ie: button in LC, It is cloned to another tiny palette without a toolbar. Is that correct..?

Re: Creating your own tools palate

Posted: Fri Apr 20, 2012 5:24 pm
by mwieder
Gary-

Yes, that's correct. Both PowerTools and DropTools use similar but slightly different approaches to the idea of creating a stack for the object so that you can drag it outside the normal LiveCode boundaries. Ken and I have also taken pains to ensure maximum compatibility between PowerTools widgets and DropTools controls, so that for the most part they should be interchangeable.

To be clever about creating a drag stack, you'd also want to set the windowshape of the drag stack to look like and have the size of the draggable object. You can look at the code of either DropTools or PowerTools (there's a trial version on revOnline) to see how the creation and dragging of objects is done, but I should warn you that there's a lot of work involved. The Bits themselves aren't that hard, but there are a lot of Bits.

Another approach is the one taken by MetaCard, where you click on an object in the palette to select the tool/object you're going to put into a stack, then draw a placement rectangle in the destination stack, and then copy the object to the destination and set its rect. This is a much easier thing to code, and you can take a look at the MetaCard stacks to see how it's done.

Re: Creating your own tools palate

Posted: Mon Apr 23, 2012 12:33 am
by marksmithhfx
Thanks for the suggestions guys... I'll get started with that and see how far I get.

-- Mark