Thread Tools Display Modes
09-09-24, 11:18 AM   #1
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 136
Mouseover Issue in WeakAuras

Hello,

I'm working on a WeakAura that gives users the option to allow mouseover opacity on a select element. Everything's been going well, but I hit a snag with the mouseover script.

To preface, when the user toggles a mouseover checkbox in the Custom Options tab, it'll update an "isMouseover" variable on the specified element. This part works fine. However, within the "OnEnter" script, when trying to access the "isMouseover" variable, it comes back as nil.

Lua Code:
  1. aura_env.UpdateMouseover = function()
  2.     for _,v in pairs(aura_env.config) do
  3.         if (v.elementID ~= "" and v.isMouseover) then
  4.             local element = _G[v.elementID]
  5.            
  6.             element.isMouseover = v.isMouseover
  7.             element.noCombatOpacity = v.noCombatOpacity
  8.             element.combatOpacity = v.combatOpacity
  9.             element.mouseoverCombatOpacity = v.mouseoverCombatOpacity
  10.             element.mouseoverNoCombatOpacity = v.mouseoverNoCombatOpacity
  11.            
  12.             print("Is Mouseover:",self.isMouseover) -- returns true/false
  13.  
  14.             element:SetScript("OnEnter",function(self)
  15.                     print("Is Mouseover in Script:",self.isMouseover) -- returns nil
  16.  
  17.                     if (self.isMouseover) then -- doesn't work
  18.                         if (UnitAffectingCombat("player")) then
  19.                             self:SetAlpha(self.mouseoverCombatOpacity)
  20.                         else
  21.                             self:SetAlpha(self.mouseoverNoCombatOpacity)
  22.                         end
  23.                     end
  24.             end)
  25.            
  26.             if (UnitAffectingCombat("player")) then
  27.                 element:SetAlpha(element.combatOpacity)
  28.             else
  29.                 element:SetAlpha(element.noCombatOpacity)
  30.             end
  31.         end
  32.     end
  33. end

I noticed that even if I run aura_env.UpdateMouseover() at WA_DELAYED_PLAYER_ENTERING_WORLD, element.isMouseover won't exist until I open WeakAuras' options, which I'm assuming means at the time of SetScript(), the .isMouseover variable doesn't exist on the variable yet. I'm not sure how to get around this :/

Last edited by Sweetsour : 09-09-24 at 12:51 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Mouseover Issue in WeakAuras


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off