Thread Tools Display Modes
04-23-13, 10:58 PM   #1
dorn
A Defias Bandit
Join Date: Dec 2009
Posts: 2
Secure frame visibility question.

I'm trying to learn how to use the secure templates/handlers and I've hit something confusing. Everything I read implies hiding/showing action frames in combat is restricted to macro conditionals.

How do things like OPie work though? You press a hotkey and an action frame appears then executes whatever radial choice you make. I know Aura Frames also has a popup cancel-buffs-in-combat frame as well.

I've tried looking through the code of such addons but it's a bit much to tackle all at once. Am I misunderstanding the hide/show restrictions or something? Any help is appreciated.
  Reply With Quote
04-24-13, 03:50 AM   #2
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
You need to seperate this into the event that triggers the effect you want to achieve.

I was in the same boat here:
http://www.wowinterface.com/forums/s...ad.php?t=46227

Some good reads are:
http://www.iriel.org/wow/docs/Secure...20-%20pre1.pdf
http://www.wowwiki.com/SecureHandlers

The following secure templates are supported
Lua Code:
  1. SecureHandlerBaseTemplate
  2. SecureHandlerStateTemplate
  3. SecureHandlerAttributeTemplate
  4. SecureHandlerClickTemplate
  5. SecureHandlerDoubleClickTemplate
  6. SecureHandlerDragTemplate
  7. SecureHandlerMouseUpDownTemplate
  8. SecureHandlerMouseWheelTemplate
  9. SecureHandlerEnterLeaveTemplate

If you have a button that should trigger sth onclick you can work with the SecureHandlerClickTemplate.

If sth in your environment changes (group, combat) it is probably best to use the SecureHandlerStateTemplate.

Here is an example for a click handler that will work securely in combat:
Lua Code:
  1. --the frame
  2. local myFrame = CreateFrame("Frame", nil, UIParent)
  3. myFrame:SetPoint("CENTER")
  4. myFrame:SetSize(200,200)
  5. local tex = myFrame:CreateTexture(nil, "BACKGROUND", nil, -8)
  6. tex:SetTexture(1,1,1)
  7. tex:SetVertexColor(0,1,0)
  8. tex:SetAllPoints()
  9.  
  10. --button
  11. local button = CreateFrame("BUTTON", "mySecureClickButton", UIParent, "SecureHandlerClickTemplate, UIPanelButtonTemplate")
  12. button.text = _G[button:GetName().."Text"]
  13. button.text:SetText("I'm a magic button")
  14. button:SetWidth(button.text:GetStringWidth()+20)
  15. button:SetHeight(button.text:GetStringHeight()+12)
  16. button:SetPoint("CENTER",0,250)
  17.  
  18. --onclick handler
  19. button:SetAttribute("_onclick", [=[
  20.   local ref = self:GetFrameRef("myFrame")
  21.   if not ref:GetAttribute("state") then
  22.     ref:SetAttribute("state","open")
  23.   end
  24.   local state = ref:GetAttribute("state")
  25.   if state == "closed" then
  26.     ref:SetAlpha(1)
  27.     ref:SetSize(200,200)
  28.     ref:Show()
  29.     ref:SetAttribute("state","open")
  30.     self.text:SetText("Click to close")
  31.   else
  32.     ref:SetAlpha(0.4)
  33.     ref:SetSize(50,50)
  34.     --ref:Hide()
  35.     ref:SetAttribute("state","closed")
  36.     self.text:SetText("Click to open")
  37.   end
  38. ]=])
  39.  
  40. --create a frame reference by name, you can access this frame in your onclick handler later
  41. button:SetFrameRef("myFrame", myFrame)

Inside the secure onclick handler you can do anything you want since you are in secure environment.

Btw...before you start make sure you really need secure handlers. If you never thouch secure frames in any way in your addon you can stay insecure. Insecure frames can show/hide insecure frames even in combat.
__________________
| 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-24-13 at 04:11 AM.
  Reply With Quote
04-24-13, 08:31 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Zork, FYI that wowwiki has long been replaced by wowpedia.org. All the articles have been ported over, most of which also updated.

http://www.wowpedia.org/SecureTemplates
  Reply With Quote
04-24-13, 01:13 PM   #4
dorn
A Defias Bandit
Join Date: Dec 2009
Posts: 2
Thanks for the great info Zork! I think I see where I was getting confused now. If I have a hardware event I can use show/hide. If I want visibility to change on other events I have to use macro conditionals with RegisterStateDriver.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Secure frame visibility question.


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