View Single Post
12/05/14, 07:42 PM   #1
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
ZO_PlayerInventoryTabs - m_buttonData.control vs m_button

What is the difference between these. I originally thought they were supposed to be the same thing. Am I wrong?
Lua Code:
  1. ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_button
  2. -- and
  3. 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:
  1. ZO_PlayerInventoryTabs = {
  2.    -- contains stuff and --
  3.    m_object = {
  4.       -- contains stuff and --
  5.       m_clickedButton = {
  6.          -- contains stuff and --
  7.          m_button = <button control>,
  8.          m_buttonData = {
  9.             -- contains stuff and --
  10.             control = <button control>,
  11.          }
  12.       }
  13.    }
  14. }


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:
  1. local function InvTabSwitch(_tButtonData)
  2.    -- do stuff --
  3. end
  4.  
  5. local function HookBankButtons()
  6.     local tButtons = ZO_PlayerBankTabs.m_object.m_buttons
  7.    
  8.     for k,v in pairs(tButtons) do
  9.         local tButtonData = v[1].m_object.m_buttonData
  10.         local hCallback = tButtonData.callback
  11.        
  12.         -- Make the SubMenu bar for this button & store it in tButtonData
  13.         local menuBar = MakeMenuBar(v[1])
  14.         tButtonData.FilterIt_SubMenu = menuBar
  15.        
  16.         tButtonData.callback = function(...)   
  17.                 InvTabSwitch(...)                      
  18.                 hCallback(...)
  19.             end    
  20.     end
  21. 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:
  1. -- m_buttonData passed to callback
  2. local menuBar = m_buttonData.control:GetParent()
  3. 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:
  1. ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_button
  2. -- and
  3. ZO_PlayerInventoryTabs.m_object.m_clickedButton.m_buttonData.control
Is this going to cause me more problems somewhere else?

Last edited by circonian : 12/05/14 at 09:21 PM.
  Reply With Quote