WoW:Making Draggable Frames: Difference between revisions

no edit summary
m (→‎Using OnMouseDown / OnMouseUp: Code correction; see talk page)
No edit summary
Line 10: Line 10:
=== Using OnDragStart / OnDragStop ===
=== Using OnDragStart / OnDragStop ===
The code below creates a draggable Frame widget and uses the OnDrag widget handlers to initiate dragging. Note the use of movable and enableMouse attributes:
The code below creates a draggable Frame widget and uses the OnDrag widget handlers to initiate dragging. Note the use of movable and enableMouse attributes:
<Frame name="DragFrame1" enableMouse="true" movable="true">
  <Ui>
  <Frame name="DragFrame1" enableMouse="true" movable="true">
   <Scripts>
   <Scripts>
   <OnLoad>self:RegisterForDrag("LeftButton");</OnLoad>
   <OnLoad>self:RegisterForDrag("LeftButton");</OnLoad>
Line 27: Line 28:
   <Anchors><Anchor point="CENTER" relativeTo="UIParent"/></Anchors>
   <Anchors><Anchor point="CENTER" relativeTo="UIParent"/></Anchors>
  </Frame>
  </Frame>
</Ui>


Note the use of the OnLoad Script, In order to drag a frame it must register for drag via {{api|Frame RegisterForDrag|Frame:RegisterForDrag("button")}}.
Note the use of the OnLoad Script, In order to drag a frame it must register for drag via {{api|Frame RegisterForDrag|Frame:RegisterForDrag("button")}}. Above code edited to include the <Ui> </Ui> tags as it
is .xml and won't work without this.


=== Using OnMouseUp/OnMouseDown ===
=== Using OnMouseUp/OnMouseDown ===
Anonymous user