WoW:Detecting an instant cast spell: Difference between revisions

→‎OnMouseDown: cleaned code sample slightly
(Added OnMouseDown event to list, deprecated CameraOrSelectOrMoveStart)
(→‎OnMouseDown: cleaned code sample slightly)
Line 226: Line 226:


=== OnMouseDown ===
=== OnMouseDown ===
 
   
  WorldFrame:SetScript("OnMouseDown", myMouseDown)
  function myMouseDown()
 
function myMouseDown()
     if arg1 == "LeftButton" then
     if arg1 == "LeftButton" then
         local targetName = nil
         local targetName;
 
       
         if MyMod_Spell and UnitName("mouseover") then
         if MyMod_Spell and ExistsName("mouseover") then
             targetName = UnitName("mouseover")
             targetName = UnitName("mouseover")
         end
         end
Line 243: Line 241:
         end
         end
     end
     end
end
local oldFunc = WorldFrame:GetScript("OnMouseDown");
if ( oldFunc ) then --hook the old function if one already exists
    WorldFrame:SetScript("OnMouseDown", function() oldFunc(); myMouseDown(); end );
else
    WorldFrame:SetScript("OnMouseDown", myMouseDown);
  end
  end


Anonymous user