Thread: Type DELETE!
View Single Post
08-16-15, 05:18 AM   #8
karmamuscle
A Cobalt Mageweaver
 
karmamuscle's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 205
[quote=Talyrius;310354]Here is another alternative:
Lua Code:
  1. -- confirm item destruction with delete key
  2. local addText = "\n\n|cff808080Note:|r You may also press the |cffffd200Delete|r key as confirmation."
  3. local itemDialogs = {
  4.   "DELETE_ITEM",
  5.   "DELETE_GOOD_ITEM",
  6.   "DELETE_QUEST_ITEM",
  7.   "DELETE_GOOD_QUEST_ITEM",
  8. }
  9.  
  10. for k, v in pairs(itemDialogs) do
  11.   StaticPopupDialogs[v].text = _G[v] .. addText
  12. end
  13.  
  14. local f = CreateFrame("Frame", nil, UIParent)
  15. f:RegisterEvent("DELETE_ITEM_CONFIRM")
  16. f:SetScript("OnEvent", function(self, event)
  17.   for i = 1, STATICPOPUP_NUMDIALOGS do
  18.     local dialog = _G["StaticPopup" .. i]
  19.     local editBox = _G["StaticPopup" .. i .. "EditBox"]
  20.     local isItemDialog = false
  21.     for k, v in pairs(itemDialogs) do
  22.       if dialog.which == v then
  23.         isItemDialog = true
  24.       end
  25.     end
  26.     if isItemDialog then
  27.       if editBox then
  28.         editBox:ClearFocus()
  29.       end
  30.       dialog:SetScript("OnKeyDown", function(self, key)
  31.         if key == "DELETE" then
  32.           DeleteCursorItem()
  33.         end
  34.       end)
  35.       dialog:HookScript("OnHide", function(self)
  36.         self:SetScript("OnKeyDown", nil)
  37.       end)
  38.     end
  39.   end
  40. end)

This is very neat! Love it.
Found some items it can't use the delete key for.
All the old rare tokens from Ahn'Qiraj can't be deleted with the Del key.
There was an item from Tanaan Jungle as well, but I forgot to write down the name ofc...
Update: It is Baleful tokens
__________________
55 89 144 233 377 610 987 1597 2584 4181 6765

Last edited by karmamuscle : 08-16-15 at 04:23 PM. Reason: Updated with Tanaan info
  Reply With Quote