Thread Tools Display Modes
07-19-10, 03:57 AM   #1
magges
An Aku'mai Servant
 
magges's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 36
mMenu bug - Buttons appear twice and overlap after loading screen

Hey there

ive got a problem with my Addon: http://www.wowinterface.com/download...?id=17374#info
and i dont know how to solve it :/

Everytime i join Arena or Instance etc die buttons appear once again ..that means after 3 arena matches i got 4 frames per addon.
They are overlapping but u can notice the font seems to be "bold" - after /rl it looks normally.

Think i know why i got this Error.
I create a PLAYER_ENTERING_WORLD Event to be sure it loads after other addons - so the bars will appear:

Code:
if IsAddOnLoaded("Recount") then
	recountbutton = CreateFrame("Frame", "RecountButton", menu)
	CreateAddonButton(recountbutton)
On top of the event i say:
Code:
local mmenuaddons = 0
and after any addon that loads=
Code:
mmenuaddons = mmenuaddons + 1
Here s what i dont get:
The Frame around all the buttons get the Height:

mmenuaddons * buttonHeight

but this frame doe not change his height. But the frames appears multiple times u know?
/e okay i know why: the "mmenuaddons = 0" is in the ENTERING_WORLD Event too ..
but the other problem ..i dontknow .(


Hope someone get it (english..isnt the best) and can help me

magges

Last edited by magges : 07-19-10 at 04:02 AM.
  Reply With Quote
07-19-10, 04:02 AM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
At the end of your PLAYER_ENTERING_WORLD event function, unregister the event - this makes it so after the first run it will never run again during a session.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
07-19-10, 04:14 AM   #3
magges
An Aku'mai Servant
 
magges's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 36
Thanks buut can you explain it a bit? Im not rly close to this functions id just copy this part out of another addons.

at the top:
Code:
local AddOn = CreateFrame("Frame")
local OnEvent = function(self, event, ...) self[event](self, event, ...) end
AddOn:SetScript("OnEvent", OnEvent)
then i start the function with
Code:
local function login()
at the bottom:
Code:
AddOn:RegisterEvent("PLAYER_ENTERING_WORLD")
AddOn["PLAYER_ENTERING_WORLD"] = login
what can i delete and what do i have to change?

thanks, magges

/e hm i can delete the OnEvent part, correct?
AddOn:UnregisterEvent("PLAYER_ENTERING_WORLD") ?

/e2 wont work .. i dunno how to manage this

/e3 okay i just placed
Code:
AddOn:UnregisterEvent("PLAYER_ENTERING_WORLD")
at the bottom of the "login" function.
It seems to work but .. is there a better way?

Last edited by magges : 07-19-10 at 05:11 AM.
  Reply With Quote
07-19-10, 08:09 AM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
No. That is the way you're supposed to do it. PEW fires after login *and* in those other occasions (when you see your buttons being created again). If you only want to use the event once, then you can unregister the event after you're finished with it.

Code:
login()
     --do stuff
     AddOn:UnregisterEvent("PLAYER_ENTERING_WORLD")
end
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-19-10, 08:54 AM   #5
magges
An Aku'mai Servant
 
magges's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 36
Okay thank you

Now since this works finde ive another question :P

Is it possible to say "wait 1 sec then do stuff end"?

Cause I use this MouseDown function:
Code:
		if menu:IsShown() then
			UIFrameFadeOut(menu, mmconfig.fadetime, 1, 0)
			menu:Hide()
		else
			menu:Show()			
			UIFrameFadeIn(menu, mmconfig.fadetime, 0, 1)
		end
so the menu fades in when i will open it but it instantly fades out when i wanna close it - cause its hidden. I could delete the menu:Hide() but that would be so great cause .. you can still click on the menu :P

So I wanna add a wait(mmconfig.fadetime) before the menu will be hidden. Is that possible?

magges

Last edited by magges : 07-19-10 at 08:59 AM.
  Reply With Quote
07-19-10, 09:03 PM   #6
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by magges View Post
<snip>Is it possible to say "wait 1 sec then do stuff end"?<snip>
Yes, with an OnUpdate script - just be sure to throttle it since it happenes every frame (120FPS means OnUpdate firing 120 times a second).
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » mMenu bug - Buttons appear twice and overlap after loading screen


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