Show and Hide frames on button click
I recently started to learn LUA and have been slowly picking a few stuff up and currently am stuck trying to progress further with what I want to do. So far I've learned to create a frame, add a button, and a couple widgets to it. I've also been able to turn the button into something like a macro using SetAttribute("macrotext1", "/wave") but I have been unsuccessful trying to figure out how to press a button that shows a new frame while hiding the current frame. Basically like almost turning a page.
I have managed to create a new frame by pressing the button but this creates a new frame outside of the existing one by doing something like this. Code:
frame.sBtn:SetScript("OnClick", function() |
Ok, after finally taking a break my mind was finally able to make a bit more progress but it is still incomplete from what I am trying to do. I managed to show and hide on demand by pressing the button a secondary frame I created within the file doing the following.
Code:
local newFrameHidden = false |
Lua Code:
Essentially, change the frame's shown state to what it is not now. If you wanted to hide frame at the same time, add Code:
self:GetParent():SetShown(not self:GetParent()IsShown()) If you have a button on newFrame to toggle back, use the same script in its OnClick handler only replace newFrame with frame |
All times are GMT -6. The time now is 11:55 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI