Widgets (Web API)

From PowerUI
Revision as of 10:28, 14 January 2017 by 151.229.186.156 (talk)
Jump to: navigation, search

Note: Not to be confused with the standard window object. In order to make the window system as useful as possible, it features a Web API available as document.sparkWindows. This is used to open, close, cycle, find etc windows within a document.

Available methods

See the source documents for Windows.Manager, or the source itself which is here:

PowerUI/Source/Extras/Window System/Manager.cs


Get the window that an element is in

It's often useful to obtain the window object that a particular element is in. It's as simple as this:

// HtmlElement anElement;

// Null if it's not in any window
Window myWindow=anElement.sparkWindow;

Parameters

You can pass extra parameters to an opening window via the globals dictionary:

// Create it:
Dictionary<string,object> globals = new Dictionary<string,object> globals();

// Add in a couple options:
globals["initial"]=14;

// Open a bank window using the "floating" template:
document.sparkWindows.open("floating","UIs/Bank/index.html",globals);

Just like with the window:// protocol, these parameters will be set as JavaScript globals for the content to use, and are also made available to the template.

Opening a window relative to another

It's important to note that every window is also a window manager. This lets you open a window "on top" of another one, regardless of their defined stacking order. An example of where this is useful is, for example, fading the screen out and then displaying a pause menu.