Thread: Minimap button
View Single Post
05-17-08, 11:44 AM   #3
hipjipp
A Cliff Giant
 
hipjipp's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 79
Man i suck at coding at times.. I read, ripped, scratched, petted and mended the code from bongos3's minimap code. But i can't make the damn button appear. I get no errors, but nothing shows. I'll paste the code here. (Yes, i made it orange for easy read).
Code:
local MinimapButton = CreateFrame('Button', "MainMenuBarToggler", Minimap)

function MinimapButton:Load()
    self:SetFrameStrata('HIGH')
    self:SetWidth(31)
    self:SetHeight(31)
    self:SetFrameLevel(8)
    self:RegisterForClicks('anyUp')
    self:SetHighlightTexture('Interface\\Minimap\\UI-Minimap-ZoomButton-Highlight')

    local overlay = self:CreateTexture(nil, 'OVERLAY')
    overlay:SetWidth(53)
    overlay:SetHeight(53)
    overlay:SetTexture('Interface\\Minimap\\MiniMap-TrackingBorder')
    overlay:SetPoint('TOPLEFT')

    local icon = self:CreateTexture(nil, 'BACKGROUND')
    icon:SetWidth(20)
    icon:SetHeight(20)
    icon:SetTexture('Interface\\Icons\\Spell_ChargeNegative')
    icon:SetTexCoord(0.05, 0.95, 0.05, 0.95)
    icon:SetPoint('TOPLEFT', 7, -5)
    self.icon = icon

    self:SetScript('OnClick', self.OnClick)

    self:SetPoint("BOTTOMRIGHT", Minimap, "BOTTOMRIGHT", -2, 2)
end
     
  function MinimapButton:OnClick(button)
    if button == 'LeftButton' then
        MainMenuBar:ClearAllPoints()
        MainMenuBar:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, -300)
    elseif button == 'RightButton' then
        MainMenuBar:ClearAllPoints()
        MainMenuBar:SetPoint("BOTTOM", UIParent, "BOTTOM", 0, 10)
    end
end 
Edit: Changed the color of the code and cleaned it up a bit for people wanting to steal it...

Last edited by hipjipp : 05-18-08 at 09:31 AM. Reason: cleanup
  Reply With Quote