Thread Tools Display Modes
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
03-10-24, 03:48 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
This is code I got from the official action button file and incorporated into my own button.

Lua Code:
  1. -- Get the binding key ( if any ) for this button and display it
  2.     local key = GetBindingKey("CLICK "..DFMB:GetName()..":LeftButton")
  3.     local text = GetBindingText(key, 1)
  4.     if ( text == "" ) then
  5.         DFMB.HotKey:Hide()
  6.     else
  7.         DFMB.HotKey:SetText(text)
  8.         DFMB.HotKey:Show()
  9.     end

This is the part of the official code I based it on.
https://github.com/Gethe/wow-ui-sour...utton.lua#L453

Hopefully it will help see where you might be going wrong. Because my button isn't based on a Blizzard template ( it doesn't have to be a secure frame ) I had to set up the related Binding information such as a localized global string and a Bindings.xml file set up with the binding key chosen by the player.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
03-10-24, 05:28 AM   #3
wmcarlos
A Defias Bandit
Join Date: Mar 2024
Posts: 2
Originally Posted by Xrystal View Post
This is code I got from the official action button file and incorporated into my own button.

Lua Code:
  1. -- Get the binding key ( if any ) for this button and display it
  2.     local key = GetBindingKey("CLICK "..DFMB:GetName()..":LeftButton")
  3.     local text = GetBindingText(key, 1)
  4.     if ( text == "" ) then
  5.         DFMB.HotKey:Hide()
  6.     else
  7.         DFMB.HotKey:SetText(text)
  8.         DFMB.HotKey:Show()
  9.     end

This is the part of the official code I based it on.
https://github.com/Gethe/wow-ui-sour...utton.lua#L453

Hopefully it will help see where you might be going wrong. Because my button isn't based on a Blizzard template ( it doesn't have to be a secure frame ) I had to set up the related Binding information such as a localized global string and a Bindings.xml file set up with the binding key chosen by the player.
Oh yeah, thanks a lot!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can't SetText for HotKey


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