View Single Post
12/05/14, 09:34 PM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
This is a little offtopic, but all button data is stored in tabFilters table, so it would be easier to work with this table:
Lua Code:
  1. local function InvTabSwitch(_tButtonData)
  2.     -- do stuff --
  3. end
  4.      
  5. local function HookBankButtons()
  6.     local inventory = PLAYER_INVENTORY:GetDisplayInventoryTable(INVENTORY_BANK)
  7.     local tabFilters = inventory.tabFilters
  8.        
  9.     for k,tButtonData in pairs(tabFilters) do
  10.         local hCallback = tButtonData.callback
  11.            
  12.         -- Make the SubMenu bar for this button & store it in tButtonData
  13.         local button = inventory.filterBar:ButtonObjectForDescriptor(tButtonData.descriptor)
  14.         local menuBar = MakeMenuBar(button.m_button)
  15.         tButtonData.FilterIt_SubMenu = menuBar
  16.  
  17.         tButtonData.callback = function(...)
  18.                 InvTabSwitch(...)                      
  19.                 hCallback(...)
  20.             end    
  21.     end
  22. end

EDIT: As merlight has explained, "buttonData.control" is not supported by MenuBar / MenuBarButton class and it is not correctly updated by inventory manager. So, I have updated code to get button from descriptor.

Last edited by Garkin : 12/05/14 at 11:41 PM.
  Reply With Quote