WoW:API Frame StartMoving: Difference between revisions

marginally closer to bp, setuserplaced note
(Updated with new information (behavior of StartMoving(),StopMovingOrSizing() on frames with a non-UIParent anchor frame))
(marginally closer to bp, setuserplaced note)
Line 1: Line 1:
{{widgetmethod}}
{{widgetmethod}}
Moves the frame-based object in relation to where the mouse is being moved.
Moves the frame-based object in relation to where the mouse is being moved.
frame:StartMoving();


obj:StartMoving();
== Details ==
 
* Use this with the [[API RegisterForDrag|RegisterForDrag()]] function and the <OnDragStart>...</OnDragStart> event 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.
;''Arguments''
* Moving a frame using this function sets the user placed flag for the frame, making the client save its position and reposition the frame on reload. To avoid this behavior, you can call frame:[[API Frame SetUserPlaced|SetUserPlaced]](false) immediately after StopMovingOrSizing().
 
:;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 [[API RegisterForDrag|RegisterForDrag()]] function and the <OnDragStart>...</OnDragStart> event 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.
*For pixel-precise movements, you should instead use [[API EnableMouse|EnableMouse()]] and the <OnMouseDown>...</OnMouseDown> and <OnMouseUp>...</OnMouseUp> events (and probably also the <OnHide>...</OnHide> event).
*For pixel-precise movements, you should instead use [[API EnableMouse|EnableMouse()]] and the <OnMouseDown>...</OnMouseDown> and <OnMouseUp>...</OnMouseUp> events (and probably also the <OnHide>...</OnHide> event).
;''Notes''
*If the frame becomes stuck by any cause (see [[API SetClampedToScreen|SetClampedToScreen()]]), the mouse and the frame will go out-of-sync.
*If the frame becomes stuck by any cause (see [[API SetClampedToScreen|SetClampedToScreen()]]), the mouse and the frame will go out-of-sync.
*This function together with [[API StopMovingOrSizing|StopMovingOrSizing()]] exhibit some "special" behavior that can cause problems when used with frames that are not anchored to UIParent (or some other full-screen frame).
*This function together with [[API StopMovingOrSizing|StopMovingOrSizing()]] exhibit some "special" behavior that can cause problems when used with frames that are not anchored to UIParent (or some other full-screen frame).