What is the difference between these. I originally thought they were supposed to be the same thing. Am I wrong?
Lua Code:
ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_button
-- and
ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_buttonData.control
Just to give you an idea while reading this, this is what the table looks like:
Lua Code:
ZO_PlayerInventoryTabs = {
-- contains stuff and --
m_object = {
-- contains stuff and --
m_clickedButton = {
-- contains stuff and --
m_button = <button control>,
m_buttonData = {
-- contains stuff and --
control = <button control>,
}
}
}
}
When your in the backpack they always seem to be the same. If you open the mail, for example, they are no longer the same. The buttons are numbered differently in the mail than they are in the backpack even though its still ZO_PlayerInventoryTabs.
This seems to be because the mail window does not have a quest tab.
When you set a callback for the buttons like:
Lua Code:
local function InvTabSwitch(_tButtonData)
-- do stuff --
end
local function HookBankButtons()
local tButtons = ZO_PlayerBankTabs.m_object.m_buttons
for k,v in pairs(tButtons) do
local tButtonData = v[1].m_object.m_buttonData
local hCallback = tButtonData.callback
-- Make the SubMenu bar for this button & store it in tButtonData
local menuBar = MakeMenuBar(v[1])
tButtonData.FilterIt_SubMenu = menuBar
tButtonData.callback = function(...)
InvTabSwitch(...)
hCallback(...)
end
end
end
It passes m_buttonData to the callback. In the backpack it works fine, since m_buttonData.control & m_button are the same. When the callback is passed m_buttonData it contains control which is the button you pushed...but
When the mail is open because the m_buttonData.control & m_button are not the same and it causes a problem.
Your callback is still passed m_buttonData, but it only contains control which is not the button you pushed. It is the last button you pushed, which I believe is a mere coincidence due to the way the buttons get numbered and the fact that there is no quest tab in the mail window.
So what is supposed to be the difference between m_buttonData.control & m_button.
Why does the backpack pass the callback function the m_buttonData.control for the button that is pushed, but when the mail is open it passes in the wrong m_buttonData.control.
Is it just a bug?
So I figured I could just do this to grab m_button which "seems" to be the real button that was pushed.
Lua Code:
-- m_buttonData passed to callback
local menuBar = m_buttonData.control:GetParent()
local actualClickedButton = menuBar.m_object.m_clickedButton.m_button
But it leaves me wondering since I don't really know the difference between:
Lua Code:
ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_button
-- and
ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_buttonData.control
Is this going to cause me more problems somewhere else?