This site makes extensive use of JavaScript.
Please
enable JavaScript
in your browser.
Classic Theme
Thottbot Theme
Unknown errors (LUA code)
Post Reply
Return to board index
Post by
janniie
Im my addon I have made a frame with a list of different options. Each option is its own frame with its own OnClick handler. I also wanted to add a highlight when you mouseover it so I create a texture to be shown OnEnter and hidden OnLeave.
This showed to be ver hard though..
This is the principle I am using:
for i = 1,5 do
if not helpItem then
--Create the frame and bla bla...
helpItem:SetScript("OnEnter",function()
helpItem.highlight:Show()
end)
helpItem:SetScript("OnLeave",function()
helpItem:Hide()
end)
end
end
But the very odd thing is that when I do this the only highlight that is show is the last one. And it doesn't matter which of the (in this case 5) frames I mouseover! I added a print(i) to the scripts and as it turn out, it only prints "5" on every frame I enter.
Does anyone know why this happens? Any help is greatly appriciated.
~Janniie
Post by
Neffi
Well this is incorrect, obviously:
helpItem:Hide() <-- not .highlight?
But I can help you out further. All handlers get an argument referring to themselves:
helpItem:SetScript("OnEnter",function(self)
self.highlight:Show()
end)
helpItem:SetScript("OnLeave",function(self)
self.highlight:Hide()
end)
But I can help you out further still. If you set any layered-region (Texture or FontString) to the draw layer "HIGHLIGHT", it will automatically show when you mouseover, and hide when you mouseout, without you needing to do any work manually. So when you do something like:
helpItem:CreateTexture(nil, "OVERLAY")
do this instead:
helpItem:CreateTexture(nil, "HIGHLIGHT")
and exactly what you're trying to accomplish is done for you.
Edit:
Also, you need to :EnableMouse(true) for mouseover logic to work. Not sure if this includes highlight-regions, but I'm inclined to say it probably does.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.