WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Minimap button highlight dragging (https://www.wowinterface.com/forums/showthread.php?t=53791)

Benalish 06-28-16 01:48 PM

Minimap button highlight dragging
 
When I drag the minimap button along the edge, it remains the halo of highlight as you can see in the picture

This is the code:

XML code (I used nopaste service to avoid wall text)

https://nopaste.me/view/2875c949

Lua code

Lua Code:
  1. function MyMod:onMinimapButtonClick(button)
  2.     if (button == "LeftButton") then
  3.         print("foo")
  4.     end
  5.     if (button == "RightButton") then
  6.         print("bar")
  7.     end
  8. end
  9.  
  10. MyMod.mmdp = 45 -- MyMod minimap button default position
  11.  
  12. function MyMod_MinimapButton_Reposition()
  13.     MyMod_MinimapButton:SetPoint("TOPLEFT","Minimap","TOPLEFT",52-(80*cos(MyMod.mmdp)),(80*sin(MyMod.mmdp))-52)
  14. end
  15.  
  16. function MyMod:onMinimapButtonUpdate()
  17.  
  18.     local xpos,ypos = GetCursorPosition()
  19.     local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
  20.  
  21.     xpos = xmin-xpos/UIParent:GetScale()+70 -- get coordinates as differences from the center of the minimap
  22.     ypos = ypos/UIParent:GetScale()-ymin-70
  23.  
  24.     MyMod.mmdp = math.deg(math.atan2(ypos,xpos)) -- save the degrees we are relative to the minimap center
  25.     MyMod_MinimapButton_Reposition() -- move the button
  26. end

Can you help me?

Fizzlemizz 06-28-16 02:59 PM

Generally doing SetPoint without doing a ClearAllPoints first creates a second point for a frame ie. streching it from the original point to the new second (third...) point. ClearAllPoints "unlocks" the frame to locate it in a new position altogether.

The only time this doesn't apply is just after the frame is first created as it has no point set at that time.

Benalish 06-30-16 05:46 AM

Very well. You can mark this thread as solved


All times are GMT -6. The time now is 03:20 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI