You can write widgets that are based on Microsoft Silverlight, which is a browser plugin
that is described at http://silverlight.org. Silverlight uses
an XML dialect called XAML to define user interfaces and uses the
.Net platform to handle events. You can access the Silverlight runtime
code from the browser by running JavaScript™ code.
A sample named Silverlight is included
in the product, which includes the following files:
- Button.egl
introduces the following EGL external type, which extends
the Rich UI Widget type:
ExternalType Button extends Widget type JavaScriptObject
{
relativePath = "silverlight",
javaScriptName = "Button",
includeFile = "silverlight/Silverlight.html"
}
text String
{ @JavaScriptProperty
{ getMethod="getText", setMethod="setText" } };
end
As shown, the implementation language is JavaScript, and use of the Button type
requires access to Silverlight.html.
- Button.js
contains the JavaScript implementation
that is referenced in the external type definition. The JavaScript identifies the new widget and
defines the following functions:
- setText ensures
that the new widget can write
text into the DOM node
- getText ensures that
the new widget can retrieve
text from the DOM node
- egl$$update defines
an XAML fragment and enables
EGL event handling for the onClick event
- Canvas.xaml
contains an empty container for Button.js to use as
a canvas when painting a button.
- Silverlight.html
is an HTML file containing
a script tag for inclusion in the EGL-generated JavaScript.
- Demo.egl is EGL code that demonstrates use of the new widget.
Demo.egl, the code that is written for interacting with
the new
widget, is almost identical to the code that is written to interact
with the Rich UI button in the buttontest sample (file OneButton.egl);
the APIs are the same, for ease of use by the EGL developer.
You
can place the files Button.egl, Button.js, canvas.xaml and Silverlight.html in a standalone project
and store that project in a repository so that others in your organization
can use the Silverlight functionality
without their needing to maintain duplicate JavaScript implementations.
Also, you can expose additional Silverlight examples,
such as an image carousel or a videoplayer.