Thread Tools Display Modes
02-19-07, 11:28 AM   #1
mulesh
A Chromatic Dragonspawn
 
mulesh's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 193
Hiding / Showing frames

How can I get a frame to show/hide itself based on a condition?

Code:
XML
<Button name="buttonA" hidden="false">
    --Anchors, Sizes, and Layers--
    <Scripts>
        <OnUpdate>buttonA_OnUpdate()</OnUpdate>
    </Scripts>
</Button>

LUA
function buttonA_OnUpdate()
    if condition() then
        buttonA:Show();
    else
        buttonA:Hide();
    end
end
This does not work. I think because when the frame is hidden the OnUpdate handler does not fire. Could I just make a second frame to hold my OnUpdate and if condition() is true it will show my button?
  Reply With Quote
02-19-07, 11:55 AM   #2
mulesh
A Chromatic Dragonspawn
 
mulesh's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 193
I tried it, and it works great

For your viewing pleasure:
Code:
XML
<Frame name="myFrame" hidden="false" parent="UIParent">
    <Scripts>
        <OnUpdate>myFrame_OnUpdate()</OnUpdate>
    </Scripts>
</Frame>
<Button name="buttonA" hidden="false">
    --Anchors, Sizes, and Layers--
</Button>

LUA
function myFrame_OnUpdate()
    if condition() then
        buttonA:Show();
    else
        buttonA:Hide();
    end
end
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Hiding / Showing frames


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