[Drawkit] tool to create object of pre-set size then click to place?

Graham Cox graham.cox at bigpond.com
Fri Jan 1 02:22:07 PST 2010


Hi Allan,

I think what you've done is fine - I've subclassed DKObjectCreationTool for much the same purpose.

One thing you could do to finesse it, if it makes sense in your app, is to allow the mouse down to add the object as a 'pending' object, then allow it to be dragged and only added to the layer on mouse up. This would allow you to click-drag-release the object to position it exactly where you want it. While an object is 'pending' it can still have its position set as normal to allow dragging into place. A single click still achieves the same result as adding on mouse down.

--Graham

P.S. A Happy New Year to you and all DK-ers!



On 01/01/2010, at 5:26 AM, Allan Daly wrote:

> I figured something out -- here's my approach in case it's useful to anyone. I'd be glad to hear any other/better ideas on this.
> 
> I created a new "stamp tool" that is a subclass of DKObjectCreationTool. It sets the cursor with an image based on the prototype object so that when the tool is clicked the cursor changes to an image of the object that will be "stamped." On a mouse down event the prototype object is added to the target layer. If "sticky tools" are set ( [DKToolController setAutomaticallyRevertsToSelectionTool:NO]) then you can stamp/insert many of the same object over and over again.
> []

> Have fun with it, and happy 2010 everyone.
> 
> -Allan



More information about the Drawkit mailing list