This is code I got from the official action button file and incorporated into my own button.
Lua Code:
-- Get the binding key ( if any ) for this button and display it
local key = GetBindingKey("CLICK "..DFMB:GetName()..":LeftButton")
local text = GetBindingText(key, 1)
if ( text == "" ) then
DFMB.HotKey:Hide()
else
DFMB.HotKey:SetText(text)
DFMB.HotKey:Show()
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.