Thread Tools Display Modes
08-15-16, 10:18 PM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
About LibActionButton

Have anyone here used LibActionButton (LAB) library before or is using it for their addons now?

I was trying to get some information about this, but there was not many info or tutorials provided.

Although the API page provides some basic example, its interaction with some Blizzard APIs like :SetAttribute() and RegisterStateDriver() are still complex for me to deal with.

I'm aware of that Bartender4 uses LAB, but it was kinda difficult for myself to understand.
(It was same for ElvUI...)

If no one here uses LAB, could I at least get some explanation regarding :SetAttribute() and RegisterStateDriver() functions?

Thank you!
  Reply With Quote
08-17-16, 04:43 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
SetAttribute and RegisterStateDriver are not specific to LibActionButton. They are part of the Blizzard secure frame/header system.

SetAttribute does exactly what it sounds like -- sets an attribute's value.

button:SetAttribute("cows", "moo")
print(button:GetAttribute("cows")) ==> "moo"


On their own, attributes don't do anything. It's just a way of storing data on the button, pretty much the same as just using button.cows = "moo" except it can work within the secure environment. However, certain attribute names are used by other Blizzard code. For example, on an action button, attributes like "type" and "spell" will control what happens when you click the button.

RegisterStateDriver lets you automatically update states (which are really just attributes) based on macro conditionals. As with regular attributes, certain state names and values have built-in behavior. For example, the "visibility" state, when its value evaluates to "show" or "hide", will cause the frame to be shown or hidden.

RegisterStateDriver(frame, "visibility", "[combat] show; hide")

^ This will cause the frame to be shown in combat, and hidden at all other times.

You can read the Blizzard code for RegisterStateDriver and related functions here:
https://www.townlong-yak.com/framexm...tateDriver.lua

Code related to attributes in general can be found in all the FrameXML/Secure*.lua files.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
08-17-16, 07:54 AM   #3
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by Phanx View Post
SetAttribute and RegisterStateDriver are not specific to LibActionButton. They are part of the Blizzard secure frame/header system.

SetAttribute does exactly what it sounds like -- sets an attribute's value.

button:SetAttribute("cows", "moo")
print(button:GetAttribute("cows")) ==> "moo"


On their own, attributes don't do anything. It's just a way of storing data on the button, pretty much the same as just using button.cows = "moo" except it can work within the secure environment. However, certain attribute names are used by other Blizzard code. For example, on an action button, attributes like "type" and "spell" will control what happens when you click the button.

RegisterStateDriver lets you automatically update states (which are really just attributes) based on macro conditionals. As with regular attributes, certain state names and values have built-in behavior. For example, the "visibility" state, when its value evaluates to "show" or "hide", will cause the frame to be shown or hidden.

RegisterStateDriver(frame, "visibility", "[combat] show; hide")

^ This will cause the frame to be shown in combat, and hidden at all other times.

You can read the Blizzard code for RegisterStateDriver and related functions here:
https://www.townlong-yak.com/framexm...tateDriver.lua

Code related to attributes in general can be found in all the FrameXML/Secure*.lua files.
Hi Phanx,

Thank you for your detailed explanations!

I really appreciate it
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » About LibActionButton


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