Code:
function LoadMinimapButton()
local dragMode = nil --"free", nil
local function moveButton(self)
if dragMode == "free" then
local centerX, centerY = Minimap:GetCenter()
local x, y = GetCursorPosition()
x, y = x / self:GetEffectiveScale() - centerX, y / self:GetEffectiveScale() - centerY
self:ClearAllPoints()
self:SetPoint("CENTER", x, y)
else
local centerX, centerY = Minimap:GetCenter()
local x, y = GetCursorPosition()
x, y = x / self:GetEffectiveScale() - centerX, y / self:GetEffectiveScale() - centerY
centerX, centerY = math.abs(x), math.abs(y)
centerX, centerY = (centerX / math.sqrt(centerX^2 + centerY^2)) * 76, (centerY / sqrt(centerX^2 + centerY^2)) * 76
centerX = x < 0 and -centerX or centerX
centerY = y < 0 and -centerY or centerY
self:ClearAllPoints()
self:SetPoint("CENTER", centerX, centerY)
end
end
local button = CreateFrame("Button", "DPMMinimapButton", Minimap)
button:SetHeight(25)
button:SetWidth(25)
button:SetFrameStrata("MEDIUM")
button:SetPoint("CENTER", 75.70,-6.63)
button:SetMovable(true)
button:SetUserPlaced(true)
button:SetNormalTexture("Interface\\HelpFrame\\HotIssueIcon.blp")
button:SetPushedTexture("Interface\\HelpFrame\\HotIssueIcon.blp")
button:SetHighlightTexture("Interface\\Minimap\\UI-Minimap-Background.blp")
button:SetScript("OnMouseDown", function(self, button)
if IsShiftKeyDown() and IsAltKeyDown() then
dragMode = "free"
self:SetScript("OnUpdate", moveButton)
elseif IsShiftKeyDown() or button == "RightButton" then
dragMode = nil
self:SetScript("OnUpdate", moveButton)
end
end)
button:SetScript("OnMouseUp", function(self)
self:SetScript("OnUpdate", nil)
end)
button:SetScript("OnClick", function(self, button)
if IsShiftKeyDown() or button == "RightButton" then return end
DPMShowInterface()
end)
button:SetScript("OnEnter", function(self)
GameTooltip_SetDefaultAnchor(GameTooltip, self)
GameTooltip:SetText("Deadly Pvp Mods", 1, 1, 0)
GameTooltip:AddLine("version: "..DPM_version.." ",0, 1, 1, 1)
GameTooltip:AddLine(" ")
GameTooltip:AddLine("Shift+click or right-click to move\nAlt+shift+click for free drag&drop", 1, 1,1, 1)
GameTooltip:Show()
end)
button:SetScript("OnLeave", function(self)
GameTooltip:Hide()
end)
end
I want to make a box at interface addon menu and hide or show by clicking there. Can you help me?