WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   kgPanels - Script Mouseover Combat (https://www.wowinterface.com/forums/showthread.php?t=57722)

Wolly_44 12-08-19 09:01 PM

kgPanels - Script Mouseover Combat
 
Hey guys,

First post here because I'm completely stuck trying to correctly script the following function in kgPanels.

I have a kgPanel for my chat, and I want to hide the panel & chat frame when I enter combat, that part was easy, I just used the following instructions to hide/show the panel when entering/leaving combat.


Code:

OnLoad

self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")

OnEvent

if event == "PLAYER_REGEN_ENABLED" then
  self:Hide()
elseif event == "PLAYER_REGEN_DISABLED" then
  self:Show()
end

But I still want to be able to reveal it via mousover during combat if needed, I have Details! damage meter and this has the function built in and it works perfectly, I can have the window hidden during combat but mousover to reveal it if needed during a fight.

I've tried adjusting the same
Code:

if event == "PLAYER_REGEN_DISABLED"
into the OnEnter/OnLeave sections of the panel so that if my regen is disabled (in combat) then OnEnter show the panel, or if regen is disabled then hide the panel.

I dont want to hide the panel on mouseover outside of combat, can anyone help me fill in the gaps i'm missing to get this working?

Thanks in advance for any help :D

Seerah 12-08-19 10:02 PM

Hiding a panel is not the same as making it "invisible". When your panel is hidden, it's not there to mouse over. Think of hiding a panel as putting it away. Change its alpha instead.

Wolly_44 12-08-19 11:00 PM

Thank you for your help!

I have now adjusted the OnEvent to the following:
Code:

if event == "PLAYER_REGEN_DISABLED" then
  self:SetAlpha(0)
  ChatFrame1:SetAlpha(0)
elseif event == "PLAYER_REGEN_ENABLED" then
  self:SetAlpha(1)
  ChatFrame1:SetAlpha(1)
end

And I've also changed the OnEnter/OnLeave scripts to the following:
Code:

if event == "PLAYER_REGEN_DISABLED" then
  self:SetAlpha(1)
  ChatFrame1:SetAlpha(1)
end

Once I enter combat, all works well, the panel & chatframes are not visible until I leave combat, but when I mouseover the panel nothing is reappearing until I leave combat again.

Are my OnEnter/OnLeave statements incorrect?

EDIT: I can get the mouseover to work regardless of combat status, I just want to know how to script it so that when I am out of combat the mousover is disabled

Thanks again!

Seerah 12-11-19 02:23 PM

There is no event return for mouseovers. You have to explicitly check to see if you are in combat using the InCombatLockdown function.

Wolly_44 12-15-19 08:48 AM

This has definitely put me in the right direction :D Thank you so much!
Still unable to find the exact string required for my desired result but this has been very helpful!
I'm just not sure how to tie this to the OnEnter/OnLeave handles available in kgPanels.

Seerah 12-15-19 03:24 PM

In your OnEnter:
Lua Code:
  1. if InCombatLockdown() then  --if you are in combat then
  2.      self:SetAlpha(0)
  3.      ChatFrame1:SetAlpha(0)
  4. end


All times are GMT -6. The time now is 10:55 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI