So in my script I've got a dockable panel with a bunch of buttons created with this code:
Code: Select all
function createUI(thisObj)
{
myPanel = ( thisObj instanceof Panel) ? thisObj : new Window("palette", "Your Panel Name", undefined, {resizeable:true});
var editBtn = myPanel.add("button",{x:100,y:0,width:75,height:20}, "Edit");
editBtn.onClick = function () {onEditButtonClick(myPanel);};
addButtons(myPanel);
}
The addButtons(myPanel) is an external function that adds more buttons to the panel. The onEditButtonClick(myPanel) function opens up a floating window with more options so you can customize the contents of the docked panel (I'm trying to implement functionality similar to ft_ToolBar). The problem I'm running into is trying to update the contents of the docked panel after closing the floating window. Right now, as a first step to understanding the issue I'm just trying to clear all the buttons from the docked panel upon closing the floating window with this code that is executed when you close the window:
Code: Select all
function onClose(edit_palette,main_palette)
{
edit_palette.close();
var count = myPanel.children.length;
alert(count);
for(var i = 0;i<count;i++)
{
myPanel.remove(myPanel.children[i]);
}
}
For whatever reason, this code only removes
every other button from the docked panel and it's driving me mad.
Especially so because if I replace the line
Code: Select all
myPanel.remove(myPanel.children[i]);
with
it alerts all the button names, so it's obviously iterating through them all. I just can't seem to get it to remove them all. Wtf? Anyone have any guidance?
Please help!
Thanks!!!