Thread Tools Display Modes
05-25-23, 03:59 AM   #1
BloodDragon
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2017
Posts: 32
Help with Minimap Button for Addon

Hello at all, i need help with a minimap button for an addon.
I want to make a minimap button for it so you don't have to type /gt in the chat all the time.
it would be very nice if someone could help me with this.
Attached Files
File Type: zip GildenSteuer.v.4.9.zip (204.1 KB, 34 views)
  Reply With Quote
05-25-23, 05:01 AM   #2
BloodDragon
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2017
Posts: 32
That is what i have at this time.
lua:
Lua Code:
  1. MyMod_Settings = {
  2.     MinimapPos = 45
  3. }
  4.  
  5. function MyMod_MinimapButton_Reposition()
  6.     MyMod_MinimapButton:SetPoint("TOPLEFT","Minimap","TOPLEFT",52-(80*cos(MyMod_Settings.MinimapPos)),(80*sin(MyMod_Settings.MinimapPos))-52)
  7. end
  8.  
  9. function MyMod_MinimapButton_DraggingFrame_OnUpdate()
  10.  
  11.     local xpos,ypos = GetCursorPosition()
  12.     local xmin,ymin = Minimap:GetLeft(), Minimap:GetBottom()
  13.  
  14.     xpos = xmin-xpos/UIParent:GetScale()+70
  15.     ypos = ypos/UIParent:GetScale()-ymin-70
  16.  
  17.     MyMod_Settings.MinimapPos = math.deg(math.atan2(ypos,xpos))
  18.     MyMod_MinimapButton_Reposition()
  19. end
  20.  
  21. function MyMod_MinimapButton_OnClick()
  22.     DEFAULT_CHAT_FRAME.editBox:SetText("/gt")
  23.     ChatEdit_SendText(DEFAULT_CHAT_FRAME.editBox, 0)
  24. end

xml:
Lua Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  2. ..\FrameXML\UI.xsd">
  3.  
  4.     <Script file="GildenSteuerMiniMapButton.lua"/>
  5.  
  6.     <Button name="MyMod_MinimapButton" parent="Minimap" enableMouse="true" movable="true" hidden="false">
  7.         <Size>
  8.             <AbsDimension x="33" y="33"/>
  9.         </Size>
  10.         <Anchors>
  11.             <Anchor point="TOPLEFT"/>
  12.         </Anchors>
  13.         <Layers>
  14.             <Layer level="BACKGROUND">
  15.                 <Texture name="MyMod_MinimapButton_Icon" file="Interface\Icons\inv_misc_notefolded2a">
  16.                     <Size>
  17.                         <AbsDimension x="21" y="21"/>
  18.                     </Size>
  19.                     <Anchors>
  20.                         <Anchor point="TOPLEFT">
  21.                             <Offset>
  22.                                 <AbsDimension x="7" y="-6"/>
  23.                             </Offset>
  24.                         </Anchor>
  25.                     </Anchors>
  26.                 </Texture>
  27.             </Layer>
  28.             <Layer level="OVERLAY">
  29.                 <Texture file="Interface\Minimap\MiniMap-TrackingBorder">
  30.                     <Size>
  31.                         <AbsDimension x="56" y="56"/>
  32.                     </Size>
  33.                     <Anchors>
  34.                         <Anchor point="TOPLEFT"/>
  35.                     </Anchors>
  36.                 </Texture>
  37.             </Layer>
  38.         </Layers>
  39.         <Frames>
  40.             <Frame name="MyMod_MinimapButton_DraggingFrame" hidden="true">
  41.                 <Scripts>
  42.                     <OnUpdate>
  43.                         MyMod_MinimapButton_DraggingFrame_OnUpdate()
  44.                     </OnUpdate>
  45.                 </Scripts>
  46.             </Frame>
  47.         </Frames>
  48.         <HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
  49.         <Scripts>
  50.             <OnLoad>
  51.                 this:RegisterForClicks("LeftButtonUp","RightButtonUp")
  52.                 this:RegisterForDrag("LeftButton","RightButton")
  53.             </OnLoad>
  54.             <OnDragStart>
  55.                 this:LockHighlight()
  56.                 MyMod_MinimapButton_DraggingFrame:Show()
  57.             </OnDragStart>
  58.             <OnDragStop>
  59.                 this:UnlockHighlight()
  60.                 MyMod_MinimapButton_DraggingFrame:Hide()
  61.             </OnDragStop>
  62.             <OnClick>
  63.                 MyMod_MinimapButton_OnClick() -- do your thing in here, arg1 is mouse button clicked
  64.             </OnClick>
  65.         </Scripts>
  66.     </Button>
  67. </Ui>
But i cant move the Button. And I will add a tooltip for it.

Last edited by BloodDragon : 05-25-23 at 06:13 AM.
  Reply With Quote
05-25-23, 09:02 AM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
The easiest way to create an MM button for your addon is with LibDbIcon as it makes creating, moving, tooltips, clickable sub-menus and Addon Compartment compliance etc. pretty effortless.

If you're just more interested in the mechanics of making a frame movable using the mouse, see
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 05-25-23 at 09:22 AM.
  Reply With Quote
05-27-23, 02:09 AM   #4
BloodDragon
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Mar 2017
Posts: 32
Thx 4 the help it can be close.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Help with Minimap Button for Addon


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