Thread Tools Display Modes
09-30-14, 09:00 AM   #1
Danielps1
Guest
Posts: n/a
Mouseover visibility

Hello again,

I'm working on a Minimap addon and want to show/hide a Minimap Icon on hovering the Minimap.
I can't get my if working becasue it is expecting a function argument according to error code. This is my code:

Lua Code:
  1. MiniMapTrackingBackground:SetAlpha(0)
  2. MiniMapTracking:ClearAllPoints()
  3. MiniMapTracking:SetPoint("TOPRIGHT", Minimap, 1, 1)
  4. MiniMapTrackingButtonBorder:Hide();
  5. MiniMapTrackingButton:SetBackdropBorderColor(0, 0, 0)
  6.  
  7.  
  8. if Minimap:isMouseOver then
  9. MiniMapTrackingButton:Show();
  10. else
  11. MiniMapTrackingButton:Hide();
  12. end

thanks for the help in advance
  Reply With Quote
09-30-14, 09:09 AM   #2
sticklord
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 57
When you're calling a function you need to use (). So in your case Minimap:IsMouseOver(). But if i can understand correctly this won't fix it either since you're only running this code once, when the addon is loaded. You need to hook the script OnEnter and OnLeave on the MiniMap. So:

Lua Code:
  1. Minimap:HookScript("OnEnter", function()
  2.     MiniMapTrackingButton:Show();
  3. end)
  4.  
  5. Minimap:HookScript("OnLeave", function()
  6.     MiniMapTrackingButton:Hide();
  7. end)

Should work.
  Reply With Quote
09-30-14, 09:10 AM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Lua Code:
  1. local function OnLeave()
  2.     if not Minimap:IsMouseOver() and not MiniMapTrackingButton:IsMouseOver() then
  3.         MiniMapTrackingButton:Hide()
  4.     end
  5. end
  6.  
  7. Minimap:HookScript('OnEnter', function() MiniMapTrackingButton:Show() end)
  8. Minimap:HookScript('OnLeave', OnLeave)
  9. MiniMapTrackingButton:HookScript('OnLeave', OnLeave)

Last edited by semlar : 09-30-14 at 09:39 AM.
  Reply With Quote
09-30-14, 10:00 AM   #4
Danielps1
Guest
Posts: n/a
thanks guys! Works perfectly like I wanted to.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Mouseover visibility


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