WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Overriding stuff mixed in (https://www.wowinterface.com/forums/showthread.php?t=58177)

Banthur 08-26-20 08:32 PM

Overriding stuff mixed in
 
I'm trying to prevent the pvp match results scoreboard from showing

PVPMatchResults:SetScript("OnEvent", onevents);

even with this though - the event that triggers it is still firing on the original blizzard ui code and the frame is showing

Both my function and the original are called

is SetScript supposed to replace a handler or add one?
I've also tried SetScript("OnEvent", nil) --original still called

maybe it is because the original frame is using a mixin for its handlers?
how do I overwrite or nil out a mixin's callbacks?

Fizzlemizz 08-27-20 12:27 AM

Try:
Code:

PVPMatchResults.Onevent = onevents
and don't use:
Code:

PVPMatchResults:SetScript("OnEvent", onevents);

Banthur 08-27-20 04:00 PM

Quote:

Originally Posted by Fizzlemizz (Post 336703)
Try:
Code:

PVPMatchResults.Onevent = onevents
and don't use:
Code:

PVPMatchResults:SetScript("OnEvent", onevents);

What's the difference between the assignment and SetScript? Is there one?

I tested the assignment method today and that seems to produce the effect I wanted. I also noticed something yesterday -- the code I had originally (SetScript) *was* working; it just wasn't working in my test harness.

I was using a macro
Code:

PVPMatchResults:OnEvent("PVP_MATCH_COMPLETE")
to test the response of the elements to the event. Using this however seems to always trigger the original function on the frame, I'm not sure why.

Fizzlemizz 08-27-20 08:35 PM

The mixin created the method on the frame ie.

function frame:OnEvent(self, event, ...)
-- OnEvent code
end

the xml frames OnEvent <Script> tag tells it to use the frame method.

What I posted replaces the mixin method that gets applied to the frame with your new one ie. it just overrides the old function with the new.

Code:

PVPMatchResults:OnEvent("PVP_MATCH_COMPLETE")
That's directly calling the method applied (copied) to the frame by the mixin (the one that is overwritten by the code in my original reply).

Code:

PVPMatchResults:GetScript("OnEvent")(PVPMatchResults, "PVP_MATCH_COMPLETE")
Call the function currently assigned to the script.

SDPhantom 08-29-20 01:46 PM

Quote:

Originally Posted by Fizzlemizz (Post 336703)
Try:
Code:

PVPMatchResults.Onevent = onevents
and don't use:
Code:

PVPMatchResults:SetScript("OnEvent", onevents);

You can get away with this on dynamic frames, but the update doesn't work on functions already set as a handler. You still have to use :SetScript() to update those.


All times are GMT -6. The time now is 06:06 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI