Was curious if it's possible to override a binding to an unnamed button, using the click method.
Here are the arguments:
SetOverrideBindingClick(owner, isPriority, "key", "buttonName" [, "mouseButton"])
Since it doesn't actually take a frame reference but rather the name of the frame that should be clicked, this causes problem in dynamic environments where the buttons don't have names. Examples are plenty, but to name a few: quest log entries, POIs on the world map, garrison plots, etc. These buttons are indeed clickable, but lack names due to being dynamically added.
My idea was to add global references to these buttons, since I was hoping that the function uses the global namespace to find the button objects, but that doesn't seem to be the case. Dumping the reference node once it's been assigned does return the button in question, but it does not work in the override function as a name replacement.
This code runs fine on all buttons that are named when created. Is it possible to name these buttons post-creation?
Here's the code I'm using that doesn't work:
Lua Code:
local addOn, db = ...
local function AddReference(node)
local reference = addOn.."ReferenceNode"
_G[reference] = node
return reference
end
local function EnterNode(self, node)
if node:IsEnabled() then
local name = node:GetName() or AddReference(node)
self:OverrideBindingClick(Cursor, "CP_R_RIGHT", name, "LeftButton")
self:OverrideBindingClick(Cursor, "CP_R_LEFT", name, "RightButton")
local enter = node:GetScript("OnEnter")
node:LockHighlight()
if enter then
enter(node)
end
end
end
And here's the function wrapper that overrides the bindings:
Lua Code:
function ConsolePort:OverrideBindingClick(owner, old, button, mouseClick)
if not InCombatLockdown() then
local key1, key2 = GetBindingKey(old)
if key1 then SetOverrideBindingClick(owner, true, key1, button, mouseClick) end
if key2 then SetOverrideBindingClick(owner, true, key2, button, mouseClick) end
end
end
Edit: Adding image, demonstrating the issue.