How to restrict the drag and drop area in a canvas
NickName:user700284 Ask DateTime:2011-04-19T15:43:15

How to restrict the drag and drop area in a canvas

I have a canvas,lets say of dimensions 500x600.I have some controls inside that canvas.User can rearrange the controls by drag and drop.But I want to restrict the drag and drop within that canvas.

For example:There is a button in the canvas.User can drag and drop the button anywhere inside the canvas.But if the user tries to drag the button out of the canvas boundaries,it should stick in the canvas boundary.

How to achieve this?

Copyright Notice:Content Author:「user700284」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/5713140/how-to-restrict-the-drag-and-drop-area-in-a-canvas

Answers
divillysausages 2011-04-19T08:34:20

The signature for startDrag() is public function startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void\n\nThe second parameter allows you to pass a Rectangle to act as bounds for your DisplayObject. It won't be dragged outside of this",


More about “How to restrict the drag and drop area in a canvas” related questions

How to restrict the drag and drop area in a canvas

I have a canvas,lets say of dimensions 500x600.I have some controls inside that canvas.User can rearrange the controls by drag and drop.But I want to restrict the drag and drop within that canvas....

Show Detail

how to restrict the droppable in jquery drag/drop?

is it possible to restrict the droppable area. I want my draggable to revert back if its not completely in the draggable. here is the fiddle. http://jsfiddle.net/jWNkh/22/ I want the draggable to

Show Detail

Drag and drop the entire canvas and show a new area of the canvas

Has anyone tryed to move a entire canvas using a drag and drop method ? I mean something like open sea dragon I am developing a online game and my buildings do not fit within a 1000 x 700 pixel s...

Show Detail

drag and drop image into canvas droppable area

I was wondering if someone could conceptually walk me through this? I want to use kineticjs to drag and drop an image from my desktop into the browser canvas. However, I only want to make parts of ...

Show Detail

Restrict drag/drop for a node in jQuery?

can somebody please tell how to use this solution to solve my problem. I too want to restrict drag/drop for a node whose id has text "not" in it. jsTree drag and drop restrict folders by class he...

Show Detail

Drag and Drop Bitmap and TextView on Canvas- Android

I am trying to implement the drag and drop functionality in Android. I have a Custom View that overrides the onDraw(Canvas canvas) method to draw a Bitmap on a canvas that acts as my background. Th...

Show Detail

Restrict drag and drop for custom panel

I created custom control with panel as base class in windows C#. Now, I want to restrict the custom control designer to restrict the drag and drop other controls. How I can achive this functionalty?

Show Detail

Drag Buttons and Drop them in a specific area in the canvas to trigger other function like page change and printing text

I am new with kinect V2, windows 10. I have couple of wpf buttons at the bottom on a wpf page and i want to drag each button one by one to the central area of the canvas and drop it. This should tr...

Show Detail

kineticjs drag and drop image from dom into canvas

I have an image loaded on the dom already, and I want to be able to drag that image into a canvas and drop it into the canvas and create a kineticjs object out of it. I don't know how to make the ...

Show Detail

How we restrict datagrid column drag drop

How we restrict datagrid column drag drop... Thanks

Show Detail