PHP код:
local function ShapeshiftButton_UpdateHotkeys(self)
local id = self:GetID();
local actionButtonType = self.buttonType;
local hotkey = _G[self:GetName().."HotKey"];
local key = GetBindingKey(actionButtonType..id) or
GetBindingKey("CLICK "..self:GetName()..":LeftButton");
local text = GetBindingText(key, "KEY_", 1);
if ( text == "" ) then
hotkey:SetText(RANGE_INDICATOR);
hotkey:SetPoint("TOPLEFT", self, "TOPLEFT", 1, -2);
hotkey:Hide();
else
hotkey:SetText(text);
hotkey:SetPoint("TOPLEFT", self, "TOPLEFT", -2, -2);
hotkey:Show();
end
end
for id = 1, GetNumShapeshiftForms() do
local button = _G["ShapeshiftButton"..id];
if ( not button ) then break end
button.hotKey = button:CreateFontString("$parentHotKey", "ARTWORK", "NumberFontNormalSmallGray");
button.hotKey:SetPoint("TOPLEFT", button, "TOPLEFT", -2, -2);
button.hotKey:SetJustifyH("RIGHT");
button:SetID(id);
button.buttonType = "SHAPESHIFTBUTTON";
button:RegisterEvent("UPDATE_BINDINGS");
button:SetScript("OnEvent", ShapeshiftButton_UpdateHotkeys);
ShapeshiftButton_UpdateHotkeys(button);
id = id + 1;
end