[Fwd: Fruit basket program in XUL]

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Fwd: Fruit basket program in XUL]

Aaron Leventhal-3
Forwarded from blindprogramming mailing list. It's good if XUL becomes
known as a powerful tool within communities of developers that use
assistive technologies.

- Aaron



>From the zip archive at
http://www.EmpowermentZone.com/xul_fruit.zip

This fruit basket program is written in XUL: XML User-interface Language.
The language is a cross-platform, XML-based way of describing the user
interface of an application -- windows, controls, menus, etc.  Event
handling code is specified in seperate JavaScript files.  Also seperately
specified are stylistic information via CSS and localized language
information via DTD files.

XUL is used in open source applications and tools developed by the Mozilla
Foundation
http://mozilla.org
including Firefox and Thunderbird.  A runtime engine reads XUL
specifications and renders the application.  Gecko is one such engine:  a
C++ component that developers can embed in surrounding code of a larger
application.  Another engine is XMLRunner:  a seperate executable that
developers package with XUL files to create an application.  These engines
create custom Mozilla controls rather than native ones of the operating
system -- Windows, Linux, Mac.  Accessibility is built into their design,
however, using the appropriate API of the operating system -- MSAA, ATSPI,
etc.

The fruit basket program is executed with XULRunner.  The recommended
version for Windows is at
http://ftp.mozilla.org/pub/mozilla.org/xulrunner/releases/1.8.0.4/win32/en-us/xulrunner-1.8.0.4.en-us.win32.zip

For simplicity, I suggest unzipping the archive in the root directory of
drive C, which will create a directory called
C:\xulrunner

>From within that directory, run the following command line to initialize
the engine on your computer:
xulrunner.exe --register-global

The release notes for this 1.8 version are available at
http://developer.mozilla.org/en/docs/XULRunner_1.8.0.4_Release_Notes

The best learning material for XUL is available at
http://xulplanet.com

The main tutorial is available in a single HTML file at
http://www.xulplanet.com/tutorials/xultu/allofit.zip

I also suggest unzipping xul_fruit.zip to the root directory of drive C,
which will create the directory
C:\xul_fruit

You can then run the fruit basket program by executing the batch file
C:\xul_fruit\run.bat

The source coe is primarily in the files main.xul and main.js, pasted
below.

Jamal

[Begin content of main.xul]

<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

<dialog id="main" title="Fruit Basket" orient="horizontal"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"

onload="window.sizeToContent();"
buttons="accept,disclosure"

buttonlabelaccept="Add"
buttonaccesskeyaccept="A"
ondialogaccept="return doAdd();"

buttonlabeldisclosure="Delete"
buttonaccesskeydisclosure="D"
ondialogdisclosure="return doDelete();"

ondialogcancel="return doClose();">

<script src="main.js"/>

<label value="Fruit:" accesskey="F" control="txt_fruit"/>
<textbox id="txt_fruit"/>

<label value="Basket" accesskey="B" control="lst_basket"/>
<listbox id="lst_basket"/>

</dialog>

[End of xul_fruit.xul]

[Begin content of main.js]

function doAdd(){
var txt = document.getElementById("txt_fruit");
var sFruit = txt.value;
if (sFruit == "") {
alert("No fruit to add!");
}
else {
var lst = document.getElementById("lst_basket");
lst.appendItem(sFruit, "");
txt.value = "";
var iCount = lst.getRowCount();
var iIndex = iCount - 1;
lst.selectedIndex = iIndex;
}
return false;
}

function doDelete(){
var lst = document.getElementById("lst_basket");
var iIndex = lst.selectedIndex;
if (iIndex == -1) {
alert("No fruit to delete!");
}
else {
lst.removeItemAt(iIndex);
var iCount = lst.getRowCount();
if (iIndex == iCount) {
iIndex = iCount - 1;
}
lst.selectedIndex = iIndex;
}
return false;
}

function doClose(){
if (confirm("Close program?")) {
return true;
}
else {
return false;
}
}

[End of main.js]

__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind




_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility
Reply | Threaded
Open this post in threaded view
|

Re: [Fwd: Fruit basket program in XUL]

Charles McCathieNevile-2
On Fri, 26 Oct 2007 17:08:39 -0400, Aaron Leventhal  
<[hidden email]> wrote:

> It's good if XUL becomes
> known as a powerful tool within communities of developers that use
> assistive technologies.

Hmmm. Maybe not, if you're looking at ensuring that accessibility is still  
available on low-power machines. IMHO...

cheers

Chaals

--
Charles McCathieNevile  Opera Software, Standards Group
     je parle français -- hablo español -- jeg lærer norsk
http://my.opera.com/chaals              Try the Kestrel - Opera 9.5 alpha
_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility
Reply | Threaded
Open this post in threaded view
|

Re: [Fwd: Fruit basket program in XUL]

Aaron Leventhal-3
In reply to this post by Aaron Leventhal-3
It depends on what the particular developer needs. People still
sometimes need to write desktop apps instead of web apps. In that case
I'd rather have them use something that's cross platform and accessible,
rather than just one or the other of those.

And it's good for the Mozilla community for more people with
disabilities to be able to hack on our UI's.

- Aaron

Charles McCathieNevile wrote:

> On Fri, 26 Oct 2007 17:08:39 -0400, Aaron Leventhal
> <[hidden email]> wrote:
>
>> It's good if XUL becomes
>> known as a powerful tool within communities of developers that use
>> assistive technologies.
>
> Hmmm. Maybe not, if you're looking at ensuring that accessibility is
> still available on low-power machines. IMHO...
>
> cheers
>
> Chaals
>
_______________________________________________
dev-accessibility mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-accessibility