Minimap button
Hi again! I'd like to write a minimapbutton in lua that shows/hides my frame depending on the button i pressed. I've seen alot of them made, but never explained for newbs, and trying to steal some code will result in copy-pasta..
Please help! |
Code:
CreateFrame('Button', <Frame Name>, Minimap) |
Man i suck at coding at times.. I read, ripped, scratched, petted and mended the code from bongos3's minimap code. But i can't make the damn button appear. I get no errors, but nothing shows. I'll paste the code here. (Yes, i made it orange for easy read).
Code:
local MinimapButton = CreateFrame('Button', "MainMenuBarToggler", Minimap) |
You will undoubtably kick yourself for this but add
Code:
MinimapButton:Load() Also why have you got Code:
local B = CreateFrame('Button', "MainMenuBarToggler", Minimap) Code:
local MinimapButton = CreateFrame('Button', "MainMenuBarToggler", Minimap) and you have no drag enter leave etc. functions so arn't all the :SetScript() pointless Code:
self:SetScript('OnEnter', self.OnEnter) Code:
self:SetScript('OnClick', self.OnClick) and finally you have already set the parent of the button to Minimap in Code:
CreateFrame('Button', "MainMenuBarToggler", Minimap) Code:
self:SetParent(Minimap) |
*Slaps forehead* Yeah.. Gonna fix it now.. Really long day, thanks for helping me even though i keep asking newb questions.
Edit: about all the extra unneeded code, i tried some of them since i couldnt find what was causing (or in this case, not causing) the button to not appear. And the extra script code, i just didn't think about it at the time. |
Quote:
|
Fixed it, cleaned the code and it will be on the site later tonight for people wanting to use it. =)
|
I hate to bump an old thread, but how well does this script work? achieve basic minimap button functionality in 30000+ interface?
If so I would love to integrate this into my addon |
I looked at this same thread just this week for exactly the same reason. Other than me modifying it to handle right clicks only and changing the background texture, the code works a treat.
Edit:Not that modifying it caused a problem, just that's what I did to the code. |
I'm still coming up to speed on all this stuff and am not able to get this to work. I can only assume that this is because the code is taken out of context so I'm putting it in the wrong place or handling it wrong.
First, I get the CreateFrame line but where does that go? Anywhere in the body of the addon or does it need to live inside of a specific function? Second, what calls the :Load() function for the button frame? Do I need to register an event for the frame to cause it to trigger the load? |
In hipjipp's example, because the variable assigned to the frame has been declared 'local', I would place it at the top of the *.lua file; that is, outside any other function declaration or whatever. That way it can be referenced by any function/variable in that lua file. But only in that lua file.
If you declared it like this: Code:
MinimapButton = CreateFrame('Button', "MainMenuBarToggler", Minimap); As to the second part, you are correct in thinking you need an event to fire the :Load() method. Something like this: Code:
MinimapButton:RegisterEvent("PLAYER_ENTERING_WORLD"); |
Thanks for all the help. I wasn't able to get it to work using PLAYER_ENTERING_WORLD but ADDON_LOADED worked. Close enough. Now to figure out how to let the user move it around the minimap....
|
Quote:
Code:
--Create the button Thanks in advance. P.S. Sorry for any duff advice! :-( |
All times are GMT -6. The time now is 02:29 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI