Thread Tools Display Modes
11-02-09, 03:44 PM   #1
shkm
A Chromatic Dragonspawn
 
shkm's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 186
Question Toggling Action Buttons

Is it possible to hide/show or change the alpha of action buttons? Perhaps it requires hooking a secure function?

I started writing a simple addon to trigger one of the above on a button when "ACTIONBAR_SLOT_CHANGED" is fired, but trying to use methods Hide(), IsShown(), IsVisible(), GetAlpha(), etc., returns an error. Come to think of it, can action buttons be modified at all without modifying the entire bar? I notice that no major action bar addons have features to change individual buttons, short of making a new bar to house them.

For the record, I was getting the number of the button based on arg1 of the event "ACTIONBAR_SLOT_CHANGED" and concatenating it to what would be its respective frame name by default. Using the following in-game would work, which left me perplexed:

Code:
/run ActionButton1:Hide()
Thanks.
__________________
Quit WoW again on 17/04/2014.

Last edited by shkm : 11-02-09 at 03:45 PM. Reason: Added in-game bit
  Reply With Quote
11-02-09, 03:53 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Without knowing your error, or when you received it, it's hard to say what your problem is.

But I will tell you that you cannot hide/show secure frames while in combat.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-02-09, 04:10 PM   #3
shkm
A Chromatic Dragonspawn
 
shkm's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 186
Thank you for the prompt response, Seerah. Indeed, I should have included an error.

Code:
attempt to call method 'Hide' (a nil value)
In its current state, the code on the line in question is simply
Code:
button:Hide()
Where button holds a string containing the frame name. According to debug prints, this is correct (currently MultiBarRightButton7). Perhaps the problem is in that it's a string?

P.S. I receive this on calling a function (currently called HideMe) which takes the argument button. I'll give more info if you like, but I don't think it's relevant given the simplicity of what this function does right now.
__________________
Quit WoW again on 17/04/2014.

Last edited by shkm : 11-02-09 at 04:14 PM.
  Reply With Quote
11-02-09, 04:25 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Yes, it's because it's a string, most likely.

_G[button]:Hide()

That will look up the string (name) in the global table and get the appropriate reference to the frame for manipulation.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-02-09, 04:32 PM   #5
shkm
A Chromatic Dragonspawn
 
shkm's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 186
Works beautifully. Thank you very much.

One more question while we're at it: am I right in assuming that alpha can be changed in combat without issue?
__________________
Quit WoW again on 17/04/2014.
  Reply With Quote
11-02-09, 04:48 PM   #6
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
While I am not 100% sure in giving a Yes or No answer, I know plenty of addons that set alpha on PLAYER_REGEN_DISABLED (entering combat).
__________________
Never be satisfied with satisfactory.
  Reply With Quote
11-02-09, 05:28 PM   #7
shkm
A Chromatic Dragonspawn
 
shkm's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 186
Thank you for the response, Cralor. Indeed, having tested this I can confirm that alpha changes in combat work just fine.
__________________
Quit WoW again on 17/04/2014.
  Reply With Quote
11-02-09, 11:21 PM   #8
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Note that your buttons are still clickable.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
11-03-09, 12:18 AM   #9
nightcracker
A Molten Giant
 
nightcracker's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 716
Eehm, both solutions aren't complete I think, the one with :Hide() is reappearing when something(like a cooldown) happens to the buttons, but this one always keeps them hidden:
lua Code:
  1. local securehandler = CreateFrame("Frame", nil, nil, "SecureHandlerBaseTemplate")
  2. securehandler:WrapScript(_G["Button"], "OnShow", "self:Hide()")

Change "Button" with ur button.
  Reply With Quote
11-03-09, 10:53 AM   #10
Vrog
A Defias Bandit
Join Date: Oct 2009
Posts: 1
Originally Posted by Seerah View Post
But I will tell you that you cannot hide/show secure frames while in combat.
Actually you can, you just have to use the secure methods of doing so. One needs to study secure state handlers and how secure headers work, which is not a trivial task. But the hide/show methods can be called on buttons in combat if done correctly.

Read up on secure state handlers to find out how.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Toggling Action Buttons


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