Thread Tools Display Modes
09-20-13, 03:50 AM   #1
nishay77
A Murloc Raider
Join Date: Aug 2013
Posts: 8
Need help with hiding a SecureActionButton in combat

This simple addon I wrote uses a SecureActionButton frame and shows when a DBM pull timer is received. It is supposed to fade in (which it does), stay for as long as the pull timer is for (plus 2 seconds) and then fade out or disappear completely. However, secure frames cannot be hidden in combat. I think I am supposed to use SecureHandlers somehow, I just have no knowledge on this.

I have attached all of my code (apologies for the XML frame declaration, I will change it to LUA later).

OnUpdate is where the frame hiding is supposed to be handled. I don't want an actual event to hide the frame (like OnClick), I just want the frame hidden after the specified time is determined (this time is parsed in OnEvent).

Thanks in advance!
Attached Files
File Type: lua PrePot.lua (1.4 KB, 308 views)
File Type: xml PrePot.xml (1.7 KB, 222 views)
  Reply With Quote
09-20-13, 04:03 AM   #2
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
Hiding a secure frame in combat is relatively easy.
Code:
RegisterStateDriver(your_frame_reference,"visibility","[combat]hide;show")
You cannot however do that on a timer.
  Reply With Quote
09-20-13, 04:13 AM   #3
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,740
This is how you could do it with a secure button click handler.
Lua Code:
  1. local button = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate")
  2.  
  3. --secure onclick
  4. button:SetAttribute("_onclick", [=[
  5.   local ref = self:GetFrameRef("frame")
  6.   if ref:IsShown() then
  7.     ref:Hide()
  8.   else
  9.     ref:Show()
  10.   end
  11. ]=])
  12.  
  13. --frame reference
  14. button:SetFrameRef("frame", FrameToHide)
__________________
| 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 : 09-20-13 at 04:17 AM.
  Reply With Quote
09-20-13, 01:49 PM   #4
nishay77
A Murloc Raider
Join Date: Aug 2013
Posts: 8
Thanks you guys, but these solutions don't really help. If I cannot do this on a timer, I guess my only option is to set alpha to 0 and try not to click on it in combat.

Thanks anyway!
  Reply With Quote
09-21-13, 10:53 AM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
If this is for pre-potting, would not Dridzt's solution of hiding it on entering combat be ideal?

It's not pre-potting if you use it after you've entered combat.
  Reply With Quote
09-22-13, 11:24 AM   #6
nishay77
A Murloc Raider
Join Date: Aug 2013
Posts: 8
Yeah, adding the RegisterStateDriver option worked perfectly in tandem with what I already had, so it works as I intended it now.

Thanks for all the help everyone!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with hiding a SecureActionButton in combat


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