Difference between revisions of "Widgets (Web API)"

From PowerUI
Jump to: navigation, search
(Created page with "'''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...")
 
Line 22: Line 22:
  
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
== Parameters ==
 +
 +
You can pass extra parameters to an opening window via the globals dictionary:
 +
 +
 +
<syntaxhighlight lang="csharp">
 +
 +
// 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);
 +
 +
</syntaxhighlight>
 +
  
 
== Opening a window relative to another ==
 
== 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, [[Screen Fading (Fade to black/ Whiteouts)|fading the screen out]] and then displaying a pause menu.
 
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, [[Screen Fading (Fade to black/ Whiteouts)|fading the screen out]] and then displaying a pause menu.

Revision as of 10:27, 14 January 2017

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);


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.