如何限制牵引并在画布拖放区域 [英] How to restrict the drag and drop area in a canvas
问题描述
我有一个画布,让尺寸500x600.I有canvas.User里面的一些控件可以通过拖放drop.But重新排列控件的说,我要限制的拖放的画布中。
例如:有一个在canvas.User一个按钮就可以任意拖放按钮的canvas.But内,如果用户试图将按钮出了画布边界的,应该坚持在画布边界<。 / P>
如何实现这一目标?
为的startDrag()的签名
是公共职能的startDrag(lockCenter:布尔=假,范围:矩形= NULL):无效
第二个参数,可以传递一个矩形
作为界限的的DisplayObject
。它不会被外部此拖
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?
The signature for startDrag()
is public function startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void
The second parameter allows you to pass a Rectangle
to act as bounds for your DisplayObject
. It won't be dragged outside of this
这篇关于如何限制牵引并在画布拖放区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!