WoWInterface - View Single Post - How do I prevent a frame from showing during combat
View Single Post
10-21-19, 05:22 AM   #2
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,508
Edit: Although, I just noticed that you had got to the preventative measure but now need to control blizzards button.. best guess is to disbale the button before combat starts and restore it afterwards, similar to how I use my frames minimize button. Hopefully doing that minor change to blizzards button won't cause an issue.

I use the events that monitor regen ability and lock windows in place at that point that I don;t want being interacted with.


When regen is enabled, combat is finished and normal interaction is allowed, the opposite with disabled status.

When disabled I disable interactive buttons and enable them when regen is enabled again.

I also have an auto minimize/hide and maximize/show functionality that will change the frame to a more combat friendly shape and visibility and restore it back to its original status .. handy if you were in the middle of something and you were attacked.

This is an example from my MagePortals addon.
Lua Code:
  1. frame:SetScript("OnEvent",function(self,event,...)
  2.             local args = { ... }
  3.             if event == "PLAYER_ENTERING_WORLD" then
  4.                 frame:RegisterEvent("PLAYER_REGEN_ENABLED")
  5.                 frame:RegisterEvent("PLAYER_REGEN_DISABLED")
  6.             elseif event == "PLAYER_REGEN_DISABLED" then
  7.                 XMP_MinimizeButton_OnClick(frame.MinimizeButton,true)
  8.                 XMP_Header.MinimizeButton:Disable()
  9.                 XMP_Header.CloseButton:Disable()
  10.             elseif event == "PLAYER_REGEN_ENABLED" then
  11.                 XMP_MinimizeButton_OnClick(frame.MinimizeButton,true)
  12.                 XMP_Header.MinimizeButton:Enable()
  13.                 XMP_Header.CloseButton:Enable()
  14.             end
  15.         end)

And this is the minimizebutton_onclick function showing how the auto command works.
Lua Code:
  1. function XMP_MinimizeButton_OnClick(frame, auto)
  2.     -- Grab a local copy of the frame as we are using it alot here
  3.     local h = XMP_Header
  4.     -- If we are auto collapsing/expanding due to combat then check which action to do
  5.     if auto then                    
  6.         autoExecuted = false
  7.         -- If we are back after auto minimizing then maximize the frames
  8.         if h.autoMinimized then
  9.             XMP_Maximize(frame)
  10.             autoExecuted = true
  11.         -- Otherwise we are auto minimizing if it is maximized
  12.         elseif not h.isMinimized then
  13.             XMP_Minimize(frame)
  14.             autoExecuted = true
  15.         end        
  16.     else            
  17.         -- Handle manual collapse/expand
  19.         if h.isMinimized then
  20.             XMP_Maximize(frame)
  21.         else
  22.             XMP_Minimize(frame)
  23.         end
  24.     end
  25.     h.autoMinimized = (auto and autoExecuted and h.isMinimized and true) or false            
  26. end

Last edited by Xrystal : 10-21-19 at 05:26 AM.
  Reply With Quote