Difference between revisions of "Widget Protocol"
Line 20: | Line 20: | ||
<a href='window://floating/UIs/Bank/index.html'>Open or close the bank!</a> | <a href='window://floating/UIs/Bank/index.html'>Open or close the bank!</a> | ||
+ | |||
+ | </syntaxhighlight> | ||
+ | |||
+ | == Parameters == | ||
+ | |||
+ | You can pass extra parameters to your window via the query string. Both the template and your content will have access to them; they're also set as global JavaScript variables for your content too. | ||
+ | |||
+ | <syntaxhighlight lang="html"> | ||
+ | |||
+ | <!-- Maybe we've got some window which asks the user to select something, and we'd like to default it to option #4 --> | ||
+ | |||
+ | <a href='window://floating/UIs/SomeSelector/index.html?initial=4'>Open a selector</a> | ||
+ | |||
+ | <!-- index.html will end up with a JavaScript variable called initial which it can deal with however it wants --> | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 10:23, 14 January 2017
The window:// protocol is used from an anchor (a href='..') element to cycle a window. That means it opens the window but if you click the link a second time, it will close it. It specifies what should be inside the window and the window template to use:
<a href='window://<template name>/<path to content>'>Cycle a window</a>
Contents
Floating - the Built in template for a typical window
A template called "floating" is included by default. It is essentially a classic draggable, resizable window with a title bar (which will be set from the document.title of your content).
The content path
Your content path is a complete URI which defaults to being relative to resources://. So, for example, let's say you'd like to open up a bank inside a default floating window. Your bank UI is described in Resources/UIs/Bank/index.html. That makes your window URL look like this:
<a href='window://floating/UIs/Bank/index.html'>Open or close the bank!</a>
Parameters
You can pass extra parameters to your window via the query string. Both the template and your content will have access to them; they're also set as global JavaScript variables for your content too.
<!-- Maybe we've got some window which asks the user to select something, and we'd like to default it to option #4 -->
<a href='window://floating/UIs/SomeSelector/index.html?initial=4'>Open a selector</a>
<!-- index.html will end up with a JavaScript variable called initial which it can deal with however it wants -->
Opening a window from code
The window protocol is one way of opening up a window. If you'd like to open up a window from code, see the window web API.