The windowSwap application shown in the figure demonstrates how to distribute an application across multiple browser windows. The windowSwap example includes some of these components:
The next figure shows the General Interface DOM in the Component Hierarchy palette in General Interface Builder.
When the user clicks the Swap to/from Window button, the JavaScript function eg.windowswap.swap() is called. This function, shown below, creates and loads the window and swaps the content from the application to the browser window, swapWin. jsx3.Package.definePackage("eg.windowswap", function(pkg) {
pkg.swap = function() {
// get the pane to be swapped and its parent
var swapPane = pkg.APP.getJSXByName("blkSwappablePane");
var currentParent = swapPane.getParent();
if (currentParent.getName() == "blkWindowSwapApp") {
// if the parent is part of the main application, get or
// create the window
var w = pkg.APP.getAppWindow("swapWin");
if (w == null) {
w = pkg.APP.createAppWindow("swapWin");
w.setHeight(400);
w.setWidth(500);
w.setTitle("Swap Window");
}
// subscribe to the window closing event to return the
// content to the application when the window is closed
w.subscribe(jsx3.gui.Window.WILL_CLOSE, this, this.swap);
//now move the pane to the window
w.getRootBlock().adoptChild(swapPane);
//and show the window if it isn't already visible
if (!w.isOpen()) {
w.open();
}
w.focus();
} else {
// else if the parent is the root block of the window
var w = pkg.APP.getAppWindow("swapWin");
if(w) {
// unsubscribe from the window closing event
w.unsubscribe(jsx3.gui.Window.WILL_CLOSE, this,
this.swap);
}
// move the content back to the application
pkg.APP.getJSXByName("blkWindowSwapApp").adoptChild(
swapPane);
// and close the window
w.close();
}
};
});
|
Contents
|


