View Single Post
08-26-14, 11:31 AM   #6
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
The action buttons inherit from ActionBarButtonCodeTemplate and ActionButtonTemplate.

The old and the new ActionButtonTemplate sets OnClick to the function SecureActionButton_OnClick.

The old ActionBarButtonCodeTemplate doesn't had an Onclick script.
The new ActionBarButtonCodeTemplate sets OnClick to this script

Lua Code:
  1. <OnClick>
  2.     if (not self.draenorZoneDisabled) then
  3.         SecureActionButton_OnClick(self, button);
  4.     end
  5. </OnClick>
I've read somewhere that the 'inherits' attribute just copies the tags from the template. So, with using two templates something that is specified in both must be overwritten. As Blizzard specifies all templates from the most common to the most specific from the right to the left I guess again that the tags are copied from the right to the left.
Keeping that in mind I would say it overwrites the Onclick from ActionButtonTemplate (as the 'inherits' attribute is "ActionBarButtonCodeTemplate, ActionButtonTemplate").

That means your code

Lua Code:
  1. local button = SecureActionButton_OnClick
  2.  
  3.         local function register(val)
  4.             if val.IsProtected and val.GetObjectType and val.GetScript and val:GetObjectType()=="CheckButton" and val:IsProtected() then
  5.                 local script = val:GetScript("OnClick")
  6.                 if script==button then
  7.                     val:HookScript("OnEnter", function(self) bind:Update(self) end)
  8.                 elseif script==stance then
  9.                     val:HookScript("OnEnter", function(self) bind:Update(self, "STANCE") end)
  10.                 elseif script==pet then
  11.                     val:HookScript("OnEnter", function(self) bind:Update(self, "PET") end)
  12.                 end
  13.             end
  14.         end
won't trigger as the action buttons OnClick is not longer equal to SecureActionButton_OnClick.

Maybe you could fix this with

Lua Code:
  1. local button = ActionButton1:GetScript("OnClick")

I'm not sure if this is correct. It's just a guess.

btw: What is draenorZoneDisabled good for?
[e] Ah, it's for handling garrison action Buttons.

Last edited by Duugu : 08-26-14 at 12:14 PM.