XUL Javascript Code Completion

Get help with Spket IDE.
Post Reply
pennywise
Posts: 22
Joined: Thu Sep 11, 2008 2:18 pm

XUL Javascript Code Completion

Post by pennywise » Thu Sep 11, 2008 2:20 pm

What do I have to do, to activate the JS-Code-Completion for XUL-Objects?

Like the property "selectedCount" of a xul:listbox?

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Sep 12, 2008 6:37 am

currently the code assist does not support XUL-objects.

pennywise
Posts: 22
Joined: Thu Sep 11, 2008 2:18 pm

Post by pennywise » Fri Sep 12, 2008 6:59 am

your answer let me hope that there will be code assist soon? :)

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Sep 12, 2008 10:55 am

But how do you tell the code assist it is xul:listbox object? Could you provide an example?

pennywise
Posts: 22
Joined: Thu Sep 11, 2008 2:18 pm

Post by pennywise » Fri Sep 12, 2008 11:02 am

I don't know. I never thought about how code assist is realized in IDEs ..

how do you know that a DOM node is .. "prototypejs enhanced"?

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Sep 12, 2008 12:56 pm

for example, how do you get that dom node? using document.getElementById or something else?

pennywise
Posts: 22
Joined: Thu Sep 11, 2008 2:18 pm

Post by pennywise » Fri Sep 12, 2008 1:09 pm

ok, here is some code (foobar.xul):

Code: Select all

<prefwindow
    xmlns="there.is.only.xul">
 
    <prefpane>
        <label control="symbol" value="Stock to watch: "/>
        <listbox id="symbol" seltype="multiple">
           <listitem label="foobar" selected="true" />
           <listitem label="foobar2"/>
        </listbox>
    </prefpane>
<script type="application/x-javascript" src="extensions/content/javascript.js"/>
</prefwindow>
and the javascript.js

Code: Select all

var listbox = document.getElementById("symbol");
alert(listbox.selectedCount);
because the javascript.js is included inside a XUL-file, the "document.getElementById()" returns a XUL-Object.

EDIT: had to remove some URLs because of the board restrictions for new users

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Fri Sep 12, 2008 1:46 pm

It is possible, if you using getElementById, the code assist could detect the type of the Node automatically , otherwise, it could be done by inline comment like

Code: Select all

var listbox = /** xul:listbox */ ...
the second one is more easy to implement. I may support it in next version, but it depends, because currently I focus on javascript library like extjs and javascript debugger.

pennywise
Posts: 22
Joined: Thu Sep 11, 2008 2:18 pm

Post by pennywise » Mon Sep 15, 2008 7:40 am

Is this kind of implementation "easy" to make? If I can give you a helping hand, just ask :)

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Mon Sep 15, 2008 11:13 am

It is not difficult, but I have to parse all xul and xbl file, create and maintain an index of these informations.

pennywise
Posts: 22
Joined: Thu Sep 11, 2008 2:18 pm

Post by pennywise » Mon Sep 15, 2008 11:23 am

any websites so that I can read myself into that topic?

eric_suen
Site Admin
Posts: 678
Joined: Wed Sep 28, 2005 7:00 am
Contact:

Post by eric_suen » Mon Sep 15, 2008 11:50 am

XUL element are defined using XBL, you can find it in {firefox dir}\chrome\toolkit.jar\content\global\bindings\*.xml

Website http://developer.mozilla.org/en/XUL http://developer.mozilla.org/en/XBL have the document you needed.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest