Simple How to Hide and Show Window Help?
I'm simply trying to understand how to show and hide a from with a right mouse click. Here is the code where I think I don't have it correct. I'm remembering how I did this with Elder Scrolls Online so I was trying it this way and mixed it with a way to do it in wow that I've found online. However it's not working.
The Code for Hidding and showing the frame with right mouse click to my button. Lua Code:
Here is the entire lua code I have so far remember I'm still working on this so it's not finished at all yet. Lua Code:
Please if you write code back to me show it completely with all information and deep examples. I'm still very new to coding. |
You should be getting an error. Make sure that you have Lua errors shown in your Interface Options. Also, install an error catching addons (BugSack is an example) to catch errors that happen early in the loading process.
frame:SetHidden(false) is API from ESO. You'll need to use the frame API provided by WoW. frame:Hide() frame:Show() /edit: you also have a typo on line 34 ;) |
Oh, and another thing. Unless you ABSOLUTELY need your button to have a global name, accessible from outside of your addon, then don't bother giving it a global name. You can just do:
Lua Code:
If you DO want it to have a global name, then use the local you are assigning your button to as your reference in the Lua code. Locals are faster than global lookups. Lua Code:
/edit: heh... just noticed that you had the :SetHidden() call backwards anyway :p |
You can use frame:SetShown(). In combination with this, you can toggle a frame's visibility with the following line.
Code:
frame:SetShown(not frame:IsShown()) |
I have tried everything you've suggested also I've flipped things around re-named my frame and it's still not working. My button that I made in the code isn't working with a right click to show and hide the window. Any way here is the code as of right now. Still don't know what I'm doing wrong yet.
Lua Code:
|
I'm a little confused.
You're creating two buttons and a frame. For the second button you set up OnClick to hide itself but nothing declaring how your button should look like. (Difficult to click again once it is hidden btw) The first you set up to be dragable. Which button is supposed to do what when why? :) |
Ok here is how it goes I created a button that is movable and it can be clicked, then I created a window which is going to be my options window. Then the last part is what everyones been telling me to do to hide that options window. Now I'm showing my code because I know something is completely wrong.
What it's supposed to be is a simple button that can be right clicked to toggle my options window which in that window I'm going to add much more but right now I simply want to get this part working first. Hope this clears everything up. I'm just starting code and it's much easier for me when people explain where the code needs to go and why it needs to go there. In other words please just copy my code and put -- comments where something needs to be fixed, and tell me exactly how to fix it so I can better understand how this works exactly. |
Let's call your two objects Frame and Button. When you click on Button, you want to toggle whether Frame is shown or hidden.
To do that, you need to set an OnClick script on Button, that checks whether Frame is hidden or shown, and then shows or hides Frame as needed. The problem with your current code is that you are setting the OnClick script on Button, which is correct, but inside that script you are checking the visible status of Button, and hiding or showing Button, which is not correct -- you need to change the script to look at and toggle Frame, not Button. Also, having your questions about the same body of code randomly split across two threads is fairly confusing; I'd suggest sticking to one thread. |
Code:
local frame = CreateFrame("Button", nil, UIParent) What you are looking for is something like: Code:
local frame = CreateFrame("Button", nil, UIParent) |
My question is, why isn't the script set to run on ZBarButton? Why is there an anonymous button created to handle what the original button was intended for?
Here's my suggestion: Lua Code:
Notes on changes:
|
All times are GMT -6. The time now is 11:50 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI