View Single Post
02/01/15, 11:47 AM   #8
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,048
Just an update:

I got my wanted behaviour now by removing the item's context menu entries.
If you remove the context menu entry the ralting keybind will be automatically removed too.

I did this by pre-hooking the contexnt menu actions ZO_InventorySlotActions, function "AddSlotAction":

Lua Code:
  1. --======== RIGHT CLICK / CONTEXT MENU ==========================================
  2.     --Pre Hook the right click/context menu addition of items
  3.     ZO_PreHook(ZO_InventorySlotActions, "AddSlotAction", preAddSlotAction)

The function called:
Lua Code:
  1. --Pre Hook function for adding right click/context menu entries.
  2. --Attention: Will be executed on mouse enter on a slot in inventories
  3. --AND if you open the context menu by a mouse righ-click
  4. --To distinguish these two "events" you can use: if self.m_contextMenuMode == true then
  5. --true: Context-menu is open, false: Only mouse hoevered over the item
  6. local function preAddSlotAction(self, actionStringId, ...)
  7.  
  8. --------------------------------------------------------------------------------
  9. --Get the parent control and bag + slotIndex
  10.     local parentControl
  11.     --Chracter equipment, or normal slot?
  12.     if (not ZO_Character:IsHidden()) then
  13.         parentControl = self.m_inventorySlot
  14.     else
  15.         parentControl = self.m_inventorySlot:GetParent()
  16.     end
  17.     --No parent found? Abort
  18.     if parentControl == nil then return false end
  19.  
  20.     local bag
  21.     local slotIndex
  22.     --gotta do this in case deconstruction, or player equipment
  23.     local dataEntry = parentControl.dataEntry
  24.     --case to handle equiped items
  25.     if(not dataEntry) then
  26.         bagId = parentControl.bagId
  27.         slotIndex = parentControl.slotIndex
  28.     else
  29.         bagId = dataEntry.data.bagId
  30.         slotIndex = dataEntry.data.slotIndex
  31.     end
  32.     --case to handle list dialog, list dialog uses index instead of slotIndex and bag instead of bagId...?
  33.     if(dataEntry and not bagId and not slotIndex) then
  34.         bagId = parentControl.dataEntry.data.bag
  35.         slotIndex = parentControl.dataEntry.data.index
  36.     end
  37.  
  38. --------------------------------------------------------------------------------
  39. --CHECKING THE CONTEXT MENU ENTRIES HERE:
  40. --If you want to hide this context-menu entry you need to return TRUE, otherwise FALSE
  41.  
  42.     --Destroy item?
  43.     if    actionStringId == SI_ITEM_ACTION_DESTROY then
  44.  
  45.         --Only execute if context menu is visible?
  46.         if self.m_contextMenuMode == false then
  47.             return
  48.         end
  49.  
  50.  
  51.  
  52.         --This here will hide the "Destroy" contetx-menu entry and the keybinding in the keybind stip as well!
  53.         return true
  54.  
  55.     --Add item to crafting station, improvement, enchanting table
  56.     elseif actionStringId == SI_ITEM_ACTION_ADD_TO_CRAFT or actionStringId == SI_ITEM_ACTION_RESEARCH then
  57.  
  58.         --This here will hide the "Add to craft" and "Research" context-menu entries and the keybindings as well!
  59.         return true
  60.  
  61.     --Trade an item, mark item as junk, attach item to mail, sell item
  62.     elseif actionStringId == SI_ITEM_ACTION_TRADE_ADD or actionStringId == SI_ITEM_ACTION_MARK_AS_JUNK
  63.        or actionStringId == SI_ITEM_ACTION_MAIL_ATTACH or actionStringId == SI_ITEM_ACTION_SELL
  64.        --sell in guild shop
  65.        or actionStringId == SI_TRADING_HOUSE_ADD_ITEM_TO_LISTING then
  66.         --Is item marked with any of the FCOItemSaver icons? Then don't show the actionStringId in the contextmenu
  67.  
  68.         --This here will hide the "Add to trade", "Add to mail", "Mark as Junk", "Sell" and "Add to sell list" context-menu entries and the keybindings as well!
  69.         return true
  70.  
  71.     --Equip an item
  72.     elseif actionStringId == SI_ITEM_ACTION_EQUIP then
  73.  
  74.         --This here will hide the "Equip" context-menu entries and the keybindings as well!
  75.         return true
  76.  
  77.     --Unequip an item
  78.     elseif actionStringId == SI_ITEM_ACTION_UNEQUIP then
  79.         --Only execute if context menu is visible?
  80.         if self.m_contextMenuMode == false then
  81.             return
  82.         end
  83.  
  84.         --Only for character items
  85.         if( bag ~= nil and slotIndex ~= nil and bag == BAG_WORN) then
  86.             --Update the character window after item was unequipped
  87.             zo_callLater(function() checkMyCharacterWindowNowFunction(bag, slotIndex) end, 200)
  88.         end
  89.         return
  90.  
  91.     --Debugging:   Gives you the action string Id if you hover an item
  92.     else
  93.         d("actionStringId: " .. actionStringId .. " = " .. GetString(actionStringId))
  94.     end
  95. end

If you return true the context-menu entry and the relating keybinding will be hidden.
If you return false the context-menu entry and the relating keybinding will be shown/kept.
If you just return (nil) nothing will be changed. Maybe the same as returning false.
  Reply With Quote