WoW:API Frame StartMoving: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
(notes)
Line 28: Line 28:
: Use this with the [[API RegisterForDrag|RegisterForDrag()]] function to allow your frame-based object to be moved by the user.
: Use this with the [[API RegisterForDrag|RegisterForDrag()]] function to allow your frame-based object to be moved by the user.
: Use the [[API StopMovingOrSizing|StopMovingOrSizing()]] function inside the <OnDragStop>...</OnDragStop> XML section to stop the moving process.
: Use the [[API StopMovingOrSizing|StopMovingOrSizing()]] function inside the <OnDragStop>...</OnDragStop> XML section to stop the moving process.
;''Notes''
:If the frame becomes stuck by any cause (see [[API SetClampedToScreen|SetClampedToScreen()]]), the mouse and the frame will go off-sync.
:As for Patch 2.3, at the end of the movement the frame will automatically change anchors to the closest point of the parent, on a same-to-same basis (TOPLEFT to TOPLEFT, BOTTOM to BOTTOM...) and, apparently, there isn't a way to prevent this behaviour. This might be a problem if you intend to automatically resize the frame after a user drag - you might find it undesirably aligning itself to the new anchor point, resulting in surprising "jumping around" after a [[API SetWidth|SetWidth()]] or [[API SetHeight|SetHeight()]].

Revision as of 23:44, 17 April 2008

Widget API ← Frame < StartMoving

Moves the frame-based object in relation to where the mouse is being moved.

obj:StartMoving();

Arguments
nil

Returns
nil

Example
myAddonFrame:StartMoving();
Result
The frame named 'myAddonFrame' would start to move in relation to where the mouse is being moved.

Description
Moves the frame-based object in relation to where the mouse is being moved.
Use this with the RegisterForDrag() function to allow your frame-based object to be moved by the user.
Use the StopMovingOrSizing() function inside the <OnDragStop>...</OnDragStop> XML section to stop the moving process.
Notes
If the frame becomes stuck by any cause (see SetClampedToScreen()), the mouse and the frame will go off-sync.
As for Patch 2.3, at the end of the movement the frame will automatically change anchors to the closest point of the parent, on a same-to-same basis (TOPLEFT to TOPLEFT, BOTTOM to BOTTOM...) and, apparently, there isn't a way to prevent this behaviour. This might be a problem if you intend to automatically resize the frame after a user drag - you might find it undesirably aligning itself to the new anchor point, resulting in surprising "jumping around" after a SetWidth() or SetHeight().