Thread Tools Display Modes
08-18-16, 08:49 PM   #1
samvx
A Defias Bandit
 
samvx's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2009
Posts: 3
help with lua grid

Im trying to change cursor shape over each unit on grid.
I have some clue for it but need help to do work with every unit
Code:
local cursorGrid = "ITEM_CURSOR"

local function OnEnter(self)
SetCursor(cursorGrid)
end

GridLayoutFrame:SetScript("OnEnter", OnEnter)
Tried this, but does´nt work

Code:
local function OnEnter(self)
SetCursor("ITEM_CURSOR")
end

--GridLayoutFrame:SetScript("OnEnter", OnEnter)
--/run print(GetMouseFocus():GetName())
local GridFrame = Grid:GetModule("GridFrame")

local function WithAllGridFrames(func)
for _, frame in pairs(GridFrame.registeredFrames) do
frame:SetScript("OnEnter", OnEnter)
end
end

local GridUnitCursor = CreateFrame("Frame")
GridUnitCursor:RegisterEvent("PLAYER_ENTERING_WORLD")

GridUnitCursor:SetScript("OnEvent", function(self)
WithAllGridFrames()
WithAllGridFrames = nil
self:UnregisterEvent("PLAYER_ENTERING_WORLD")
self:SetScript("OnEvent", nil)
end)

Last edited by samvx : 08-19-16 at 01:10 PM.
  Reply With Quote
08-19-16, 07:54 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Probably:

Code:
local function onEnter(frame)
    SetCursor("ITEM_CURSOR")
end

local function hook(frame)
    frame:HookScript("OnEnter", onEnter)
end

local GridFrame = Grid:GetModule("GridFrame")
-- Catch any frames that have already been created:
GridFrame:WithAllFrames(hook)
-- and any that get created in the future:
hooksecurefunc(GridFrame, "InitializeFrame", hook)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » help with lua grid


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