Quantcast
WoWInterface - View Single Post - Error on Move Frame Addon
View Single Post
01-30-20, 12:15 AM   #8
BloodDragon
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Mar 2017
Posts: 19
Originally Posted by jeruku View Post
ADDON_LOADED triggers if, as you'd assume, an addon is loaded; this includes Load-On-Demand addons, like Blizzard_AzeriteEssenceUI. I can't recall off hand what other UI objects are LOD but you can reuse the event frame for those as needed; you can check an export of the interface files for the Blizzard_Addons which include Load-On-Demand in their TOC.
You could use LoadAddOn, but loading an addon that you likely won't use for 109 levels on a level 1 is rather pointless; I'd only recommend it if it's a UI object that can be used on any level/class/race.

Lua Code:
  1. local EventFrame = CreateFrame('Frame', nil, UIParent)
  2. EventFrame:RegisterEvent('ADDON_LOADED')
  3.  
  4. EventFrame:SetScript('OnEvent', function(self, event)
  5.     if event == 'Blizzard_AzeriteEssenceUI' then
  6.         --AzeriteEssenceUI
  7.         local MAEU = AzeriteEssenceUI
  8.         MAEU.ClearAllPoints = function() end
  9.         MAEU:SetPoint("TOPRIGHT", MinimapCluster, "BOTTOM", 45, -5)
  10.         MAEU.SetPoint = function() end
  11.         MAEU:SetMovable(true)
  12.         MAEU:SetUserPlaced(true)
  13.         MAEU:SetClampedToScreen(true)
  14.          
  15.         local MoveAzeriteEssenceUI = CreateFrame("Frame", nil, MAEU)  
  16.         MoveAzeriteEssenceUI:SetHeight(15)
  17.         MoveAzeriteEssenceUI:ClearAllPoints()
  18.         MoveAzeriteEssenceUI:SetPoint("TOPLEFT", MAEU)
  19.         MoveAzeriteEssenceUI:SetPoint("TOPRIGHT", MAEU)
  20.         MoveAzeriteEssenceUI:EnableMouse(true)
  21.         MoveAzeriteEssenceUI:SetHitRectInsets(-5, -5, -5, -5)
  22.         MoveAzeriteEssenceUI:RegisterForDrag("LeftButton")
  23.         MoveAzeriteEssenceUI:SetScript("OnDragStart", function(self, button)
  24.             if button=="LeftButton" and IsModifiedClick()then
  25.                 MAEU:StartMoving()
  26.             end
  27.         end)
  28.         MoveAzeriteEssenceUI:SetScript("OnDragStop", function(self, button)
  29.             MAEU:StopMovingOrSizing()
  30.         end)
  31.         --AzeriteEssenceUI
  32.     end
  33. end)

Doing multiple LOD objects:
Lua Code:
  1. EventFrame:SetScript('OnEvent', function(self, event)
  2.     if event == 'Blizzard_AzeriteEssenceUI' then
  3.         --AzeriteEssenceUI
  4.     elseif event == 'Blizzard_InsertNameHere' then
  5.         --InserNameHereUI mover code
  6.     end
  7. end)
I can no longer move a frame with the lua code. There is no error message, but moving the frames is no longer possible.
  Reply With Quote