- 最后登录
- 2024-6-3
- 注册时间
- 2009-10-16
- 阅读权限
- 100
- 积分
- 18803
- 纳金币
- 17488
- 精华
- 1
|
Draggable (Interactive Behavior)
Summary
Enables an object to be dragged by the mouse.
Category
Latest Behaviors
Author
Gavin Kistner
Difficulty
(Reference)
Time to Complete
5 Minutes
Downloads
Click Here
to download the associated files.
(This document covers version 2.10.1 of the 'Draggable' behavior, current as of 2005-Mar-21)
Description
The
Horizontal Only
and
Vertical Only
options for the
Constrain Drag
property causes the object to only be draggable in one direction (with respect to the screen).
If
Use Move Cursor?
is checked, the cursor will be set when the mouse is over the object, and while dragging it. Which cursor is used depends on the
Constrain Drag
setting.
The events for this behavior will fire on this behavior, and bubble to the parent object. You can use script to register event listeners on the parent object to track the various events.
If
Use Inertia?
is checked, the object will keep moving when released at the same speed and direction as when released. It will then slow to a stop over a number of seconds, specified by the
Inertia Stop Time
setting.
The
Drag Target
advanced property can be used to cause dragging one object to affect another. A common example is to attach the Draggable behavior to a titlebar for a window, and then specify the
Drag Target
as the group which holds all of the window. Dragging the title bar will move the entire group, but the user will not be able to drag the group by areas other than the title bar.
In addition to constraining the drag (in screen coordinates) you can use the Range Watcher behavior to constrain the x/y/z coordinates to stay within a certain range.
Basic Properties
Constrain Drag
Only permit the object to be dragged horizontally or vertically?
Use Move Cursor?
Show the Move cursor when the mouse is over the parent?
Use Inertia?
Cause the object to keep moving if you 'throw' it?
Advanced Properties
Inertia Stop Time
If 'Use Inertia?' is checked, the number of seconds it takes for the object to slow to a stop.
Drag Target
Object to move when the parent of this behavior is dragged.
Enable Immediately?
Enable dragging immediately, or wait for the 'Enable' action to be called?
Actions
Enable
Enables mouse dragging for the parent object.
Disable
Disable mouse dragging for the parent object.
Events
onDragStart
Fires when the parent object starts being dragged.
onDrag
Fires every frame while the parent object is being dragged.
onDragEnd
Fires when the parent object stops being dragged.
onInertia
Fires when the parent object is moving due to intertia.
onInertiaEnd
Fires when the parent object stops being dragged, and no inertia is affecting the object.
Demonstration
View Demonstration Project
Download Project File
|
|