On Fri, May 7, 2010 at 09:45, coolbloke1324 <[email protected]> wrote:
>
> Hi,
>
> In my application the user can perform a search. Each search brings up a
> separate new window with a tree and a container. Inside the container is a
> loading gif image and a label. The container is hidden with .hide();
>
> When the user clicks on an item in the tree, I need to be able to show the
> container and alter the label text.
>
> I cannot work out how to set the container to show on the window that holds
> the tree that the item that was clicked belongs to because I don't know how
> to reference the container.
>
> What I would like to do is set the container object to have an easy name
> like "statusContainer" and then do something like this:
>
> treeItem.parentWindow.statusContainer.show();
>
> Can anyone help with the correct way to access the container just by having
> the tree item that was clicked on?
>
Does this playground code demonstrate what you're trying to do?
// create the tree
var tree = new qx.ui.tree.Tree();
tree.set({
width: 150,
height: 300
});
this.getRoot().add(tree, {left: 10, top: 10});
// create and set the tree root
var root = new qx.ui.tree.TreeFolder("Desktop");
tree.setRoot(root);
// create some subitems
var f1 = new qx.ui.tree.TreeFolder("Logos");
var f2 = new qx.ui.tree.TreeFolder("TODO");
var f3 = new qx.ui.tree.TreeFile("jsmag_js9.pdf");
f3.setIcon("icon/22/mimetypes/text-html.png");
root.add(f1, f2, f3);
// create a third layer
var f11 = new qx.ui.tree.TreeFile("Logo1.png");
f11.setIcon("icon/22/mimetypes/media-image.png");
var f12 = new qx.ui.tree.TreeFile("Logo2.png");
f12.setIcon("icon/22/mimetypes/media-image.png");
var f13 = new qx.ui.tree.TreeFile("Logo3.png");
f13.setIcon("icon/22/mimetypes/media-image.png");
f1.add(f11, f12, f13);
// open the folders
root.setOpen(true);
f1.setOpen(true);
// Create a new container and add it to the window
var container = new qx.ui.container.Composite(new qx.ui.layout.HBox());
this.getRoot().add(container, { left : 180, top : 10 });
// Initially hide the container
container.hide();
// Add a label to the container
var label = new qx.ui.basic.Label("ignored text");
container.add(label);
// Associate the container and the label with the tree, for easy access
tree.setUserData("associated_container", container);
tree.setUserData("associated_label", label);
// When a node is selected, assign the node's label to the container's
// label, and display the container.
function showContainer(e)
{
// Retrieve the tree from the event
var tree = e.getTarget();
// Find out which node was selected
var selectedLabel = tree.getSelection()[0].getLabel();
// Assign the node's label to the (currently hidden) container's label
tree.getUserData("associated_label").setValue(selectedLabel);
// Make the hidden container visible
tree.getUserData("associated_container").show();
}
tree.addListener("changeSelection", showContainer, this);
Derrell
------------------------------------------------------------------------------
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel