Thread: Type DELETE!
View Single Post
08-15-15, 07:05 AM   #7
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
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)

Originally Posted by Deadlyz View Post
Nice, thanks!

Now how do I make it into an addon?
http://addon.bool.no/
  Reply With Quote