Thread Tools Display Modes
12-26-09, 09:24 PM   #1
turner850
A Deviate Faerie Dragon
Join Date: Jul 2007
Posts: 16
How to maky your frame movable

How do I make my frame moveable with the mouse?

ive tried to look at the 'creating minimap buttons' tutorial to cut out how to move stuff with the mouse.


Ive created a simple addon, I just want people to be able to move it around the screen.
  Reply With Quote
12-26-09, 09:26 PM   #2
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
f:IsMovable() or f:IsMovable(true)

Either works.
  Reply With Quote
12-26-09, 09:34 PM   #3
cloudwolf
A Black Drake
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 87
dont forget you ahve to allow the frame to regiser mouse clicks and also need to hook into events.
  Reply With Quote
12-26-09, 09:45 PM   #4
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
True, so here's the very basic you'd need to do to start with.

Code:
local f = CreateFrame("Frame", "name", parent)  -- parent is optional
f:IsMovable(true)
f:EnableMouse(true)
f:RegisterForDrag("LeftButton")  -- or "RightButton"
f:SetScript("OnDragStart", f.StartMoving)
f:SetScript("OnDragStop", f.StopMovingOrSizing)
tinsert(UISpecialFrames,f:GetName())  -- make frame close with "ESC"
Hope that helps.
  Reply With Quote
12-28-09, 11:00 AM   #5
Foxlit
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 91
WoWWiki has a HOWTO that is relevant: http://www.wowwiki.com/Making_Draggable_Frames

Originally Posted by ChaosInc
f:IsMovable() or f:IsMovable(true)

Either works.
f:IsMovable() is a getter, not a setter method; calling it as you describe has no effect.
__________________
... and you do get used to it, after a while.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to maky your frame movable


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off