Thread Tools Display Modes
10-10-06, 10:42 AM   #1
SantaClauss
A Murloc Raider
Join Date: Oct 2006
Posts: 4
Dragging Frame // Minimap Button

Hello,

I'm currently new on making mods and so on... I've been able to make a form and all I want on it, No problem, tho I'd like to know a few things.


How can I make my form draggable anywhere.

How I can make a close button which put a Minimap Icon.

Is there any predefined button, or How do I make one with my design?

Thanks,
SantaClauss.
  Reply With Quote
10-13-06, 11:28 PM   #2
SantaClauss
A Murloc Raider
Join Date: Oct 2006
Posts: 4
No one can answer me ? xD Is there a way at least to put my addon on minimap ( I'm sure there is one ) but how I do it XD.

Thanx
  Reply With Quote
10-14-06, 05:57 AM   #3
Barras
A Fallenroot Satyr
Join Date: Oct 2006
Posts: 21
I can't really help with your problem, but since no-one else is coming up with answers for you... when I'm hacking around with addons I generally pick an addon that does something similar to what I want then have a look at their code.

Seems like everyone uses slightly different ways of adding minimap buttons which I find annoying as they all end up looking and behaving differently. I'd suggest taking a look at how ItemRack's minimap button works. It uses the correct in-game minimap button border over an icon instead of the cruddy button graphics many other addons ship with.
  Reply With Quote
10-14-06, 06:18 AM   #4
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
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.
  Reply With Quote
10-21-06, 11:50 PM   #5
SantaClauss
A Murloc Raider
Join Date: Oct 2006
Posts: 4
Thanx im happy to have got an answer, if u could tell me how to get a tootltip when for example, i mouseover my form...

thanx
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Dragging Frame // Minimap Button


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