Quantcast
WoWInterface - View Single Post - Help on calling a switch function
View Single Post
04-03-15, 09:44 AM   #6
gmarco
A Frostmaul Preserver
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 290
Thanks very much sticklord !!

It works like a charm.

Lua Code:
  1. -- Tooltip code and hooksecurefunc by sticklord
  2. -- Thanks !
  3. -- ideas and discussions here:
  4. -- [url]http://www.wowinterface.com/forums/showthread.php?p=307934[/url]
  5.  
  6. local ADDON = ...
  7.  
  8. local TOOLTIPDISABLED = 1
  9. local prgname = "|cffffd200HideToolTip|r"
  10. local IN_COMBAT
  11.  
  12. hooksecurefunc(GameTooltip, "SetAction", function(self)
  13.     if (IN_COMBAT and TOOLTIPDISABLED == 1) then
  14.         self:Hide()
  15.     end
  16. end)
  17.  
  18. local f = CreateFrame("Frame")
  19. f:SetScript("OnEvent", function(self, event, ...)
  20.     if event == "PLAYER_REGEN_DISABLED" then
  21.         IN_COMBAT = true
  22.     elseif event == "PLAYER_REGEN_ENABLED" then    
  23.         IN_COMBAT = false
  24.     end
  25. end)
  26. f:RegisterEvent("PLAYER_REGEN_DISABLED")
  27. f:RegisterEvent("PLAYER_REGEN_ENABLED")
  28.  
  29. print (prgname .. ": |cffffd200/htt|r to have tooltips back or hide again")
  30.  
  31. SLASH_HTT1 = "/htt";
  32. SlashCmdList["HTT"] = function()
  33.    
  34.         if TOOLTIPDISABLED == 1 then
  35.             TOOLTIPDISABLED = 0
  36.             print (prgname .. ": tooltips enabled in combat")
  37.         else           
  38.             TOOLTIPDISABLED = 1
  39.             print (prgname .. ": tooltips disabled in combat")
  40.         end
  41. end

I have added an option to temporary reenable them if sometime you need to read tooltip again.

Here is the full code.
Thanks really very much !
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote