If this is your frame you want to be movable with the mouse:
Code:
<Frame name="MyFrame" parent="UIParent">
<Layers/>
<Frames/>
<Scripts>
<OnLoad>
MyFrame_OnLoad()
</OnLoad>
</Scripts>
</Frame>
then add the bits in bold:
Code:
<Frame name="MyFrame" parent="UIParent" movable="true" enableMouse="true">
<Layers/>
<Frames/>
<Scripts>
<OnLoad>
MyFrame_OnLoad()
</OnLoad>
<OnMouseDown>
this:StartMoving()
</OnMouseDown>
<OnMouseUp>
this:StopMovingOrSizing()
</OnMouseUp>
</Scripts>
</Frame>
The minimap button is a bit more complex. ItemRack's minimap button is made basically the same as a few of the default UI's. So you can check that code too for a better example. Basically:
1. Create a 33x33 button
2. Add a BACKGROUND layer with your icon, 21x21 offset at x=7 y=-6 from the TOPLEFT of your button.
3. Add an OVERLAY layer with texture file="Interface\Minimap\MiniMap-TrackingBorder", 56x56 from the TOPLEFT of your button (no offset)
4. Write a method to move it.
To move it there's a few different methods. Some have sliders in their options. Some let you drag the buttons directly.
I prefer the drag itself. You basically set up a (separate from the button) OnUpdate or use a timer that starts at <OnDragStart> and stops (very important it stop) at <OnDragStop>.
On that OnUpdate or timer you get the cursor position, figure out the degrees formed by the atan of your cursor position offset from the center of the minimap and move the button there and note its position so it goes back to it at next login.
-- run every .02 seconds only while mouse down on minimap button:
function MyMod_DragMinimapButton()
local xpos,ypos = GetCursorPosition()
local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
xpos = xmin-xpos/Minimap:GetEffectiveScale()+70
ypos = ypos/Minimap:GetEffectiveScale()-ymin-70
-- assume MyModSettings_MinimapPosition is a saved variable
MyModSettings_MinimapPosition = math.deg(math.atan2(ypos,xpos))
MyMod_MoveMinimapButton()
end
function MyMod_MoveMinimapButton()
local angle = MyModSettings_MinimapPosition or 0
local xpos = 80*cos(angle)
local ypos = 80*sin(angle)
MyMod_MinimapButton:SetPoint("TOPLEFT",Minimap,"TOPLEFT",52-xpos,ypos-52)
end
Remember in your PLAYER_LOGIN or VARIABLES_LOADED or whatever initialization event you use, that you call MyMod_MoveMinimapButton to move it back.
I strongly encourage making a minimap button as a learning experience. But if you want something that works out of the box you can use MyMinimapButton (
http://gello.wowinterface.com/downlo...fo.php?id=4686 ) also. It's an embedded library that handles all of the above.