View Single Post
03-10-24, 01:59 AM   #1
wmcarlos
A Defias Bandit
Join Date: Mar 2024
Posts: 2
Question Can't SetText for HotKey

I duplicated the slots (ActionButton) from the MainMenuBar by:
Code:
for i = 1, 12 do
    local originalActionButton _G["ActionButton" .. i], 
    local duplicateActionButton = CreateFrame("CheckButton", "DuplicateActionButton" .. i, ActionButtons, "ActionBarButtonTemplate")
    duplicateActionButton:SetSize(45, 45)
    if i == 1 then
        duplicateActionButton:SetPoint("LEFT", ActionButtons)
    else
        duplicateActionButton:SetPoint("LEFT", _G["DuplicateActionButton" .. (i - 1)], "RIGHT", 0, 0)
    end
    duplicateActionButton:SetAttribute("action", i); duplicateActionButton:SetAttribute("type", "action")
end


But when trying to assign text to the HotKey..:
Code:
local hotkey = _G["DuplicateActionButton" .. i .. "HotKey"]; 
hotkey:setFont("Interface\\AddOns\\Testing\\SPRODM__.OTF", 12, "OUTLINE"); 
hotkey:SetText(GetBindingText(GetBindingKey("ACTIONBUTTON" .. i), "KEY_", 1))


..nothing happens, but the RANGE_INDICATOR disappears for some slots.

I can only assign text in this way:
Code:
local hotkey2 = duplicateActionButton:CreateFontString(nil, "OVERLAY", "GameFontNormal")
hotkey2:SetPoint("TOPRIGHT", -4, -4); hotkey2:SetText(GetBindingText(GetBindingKey("ACTIONBUTTON" .. i), "KEY_", 1))
hotkey2:SetFont("Interface\\AddOns\\Testing\\SPRODM__.OTF", 12, "OUTLINE");


But in this case, it will be a simple text with a fixed color without indicating the range.

I'm in a bit of a stupor because in the game using the command /run DuplicateActionButton9.HotKey:SetText() - the text is changing, but only for those slots where there is a RANGE_INDICATOR.

I've just started learning LUA and WoW API and I don't really have a lot of free time to get into it. If anyone could help me out, that would be great.

P.S.: I've tried to be as concise as possible, but if there's anything else I need to provide, let me know.

Last edited by wmcarlos : 03-10-24 at 02:36 AM.
  Reply With Quote