Thread Tools Display Modes
04-05-09, 12:20 PM   #1
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
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)
__________________
| Simple is beautiful.
| WoWI AddOns | GitHub | Zork (WoW)

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 04-05-09 at 01:14 PM.
  Reply With Quote
04-05-09, 01:15 PM   #2
spiel2001
nUI's Author
 
spiel2001's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2008
Posts: 7,724
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
__________________

What people don't get is that I am, ultimately, an artist at heart.
My brush has two colors, 1 and 0, and my canvas is made of silicon.



Official nUI Web Site: http://www.nUIaddon.com
Official nUI Support Forum: http://forums.nUIaddon.com
My day job: http://www.presidio.com/
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » secure unit tempale button


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