Thread: OnLeave & Frame
View Single Post
01-07-17, 11:02 AM   #6
gmarco
An Onyxian Warder
 
gmarco's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 362
Originally Posted by SDPhantom View Post
You're also recreating them at every loading screen instead of just at login. You should either unregister PLAYER_ENTERING_WORLD when done or use PLAYER_LOGIN instead.
Thanks very much for your suggestions and hints.

About the second part of the problems I have changed in this way (I realized that it should be broken because sometime the buttons fonts were mangled).

I used a mix of your tips using event "PLAYER_LOGIN" and then unregister once fired.

Lua Code:
  1. local frame = CreateFrame("Frame")
  2. frame:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
  3. frame:RegisterEvent('PLAYER_SPECIALIZATION_CHANGED')
  4. frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  5. frame:RegisterEvent("PLAYER_LOGIN")
  6. frame:SetScript("OnEvent", function(self, event, ...)
  7.     BuildActiveSpec()
  8.     UpdateLDB()
  9.        
  10.     if event == "PLAYER_LOGIN" then
  11.         BuildMenu()
  12.         frame:UnregisterEvent("PLAYER_LOGIN")
  13.     end
  14. end
  15. )


Originally Posted by SDPhantom View Post
From what I can tell, Menu is firing OnLeave you mouseover the spec buttons. You might want to have a custom handler check for that before hiding itself.
Uhm ...

This works but is so ugly ?

Lua Code:
  1. Menu:SetScript('OnLeave', function()
  2.     local name = GetMouseFocus():GetName() or tostring(GetMouseFocus())
  3.     if string.sub(name,1,6) ~= "table:" then Menu:Hide() end
  4. end)

The problem is when I hovering the buttons the "name" var is something like:
table:00000149a7cf46e0

or if I exit from the frame values I get are:
WorldFrame
ChocolateBar1
etc etc ...

Thanks anyway for your suggestions.
__________________
This is Unix-Land. In quiet nights, you can hear the Windows machines reboot.
  Reply With Quote