WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   secure unit tempale button (https://www.wowinterface.com/forums/showthread.php?t=21748)

zork 04-05-09 12:20 PM

secure unit template player button
 
*edit* Got it working.

This creates a unit button for "player" that can be hovered, left and rightclicked.

Code:

    local orb1 = create_me_a_frame("Button",nil,orbanchorframe,"BACKGROUND",orbsize,orbsize,orbpoint,orbposx,orbposy,orbscale,nil,"SecureUnitButtonTemplate")
    orb1:RegisterForClicks("AnyUp")
    orb1:SetAttribute("unit", "player")
    orb1:SetAttribute("*type1", "target")
    local showmenu = function()
      ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor", 0, 0)
    end
    orb1.showmenu = showmenu
    orb1.unit = "player"
    orb1:SetAttribute("*type2", "showmenu")
    orb1:SetScript("OnEnter", UnitFrame_OnEnter)
    orb1:SetScript("OnLeave", UnitFrame_OnLeave)


spiel2001 04-05-09 01:15 PM

You need to create a method to handle the menu action. Something like this...

Code:


frame.popup = CreateFrame( "Frame", "$parent_Popup", frame, "UIDropDownMenuTemplate" );               

frame.menu = function()
   
    local popup = frame.popup;

    if popup then
                       
        local anchor = frame.popup;
        this.unit      = frame:GetAttribute( "unit" );
        this.name,
        this.server  = UnitName( this.unit );
                     
        ToggleDropDownMenu( 1, nil, popup, anchor, anchor:GetWidth()/2, anchor:GetHeight()/2 );
                   
    end           
 end



All times are GMT -6. The time now is 07:01 PM.

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