Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Event handlers on XBL widgets in a custom namespace

0 views
Skip to first unread message

Klaus Nowikow

unread,
Jun 18, 2008, 5:22:19 AM6/18/08
to
Hi!

I created a widget in XBL in my own namespace, and the users should be
able to provide event handlers (e.g. onmouseup) in their XUL file for
it.

Here is a minimal example of what I did:

example.css:
@import url(chrome://global/skin/);
@namespace url(http://my-namespace/example#);
drawing {
-moz-binding: url(example.xbl#example);
display: -moz-box;
}

example.xbl:
<?xml version="1.0" encoding="UTF-8" ?>
<bindings xmlns="http://www.mozilla.org/xbl"
xmlns:svg="http://www.w3.org/2000/svg"
>
<binding id="example"
extends="chrome://global/content/bindings/general.xml#basecontrol">
<content>
<svg:svg version="1.1" height="100px" width="100px">
<svg:circle cx="50" cy="50" r="30" fill="blue"/>
</svg:svg>
</content>
</binding>
</bindings>

The user of this widget should be able to provide 'on...' event handlers
as in this example:

example.xul
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet href="example.css" type="text/css"?>

<window
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<example xmlns="http://my-namespace/example#" id="experiment"
onmouseup="alert(event);"
/>
</window>

When I don't use a namespace for the widget, this works. Is there
something I can implement in addition to make this work in my custom
namespace?

Thank you,

Klaus

Klaus Nowikow

unread,
Jun 18, 2008, 8:30:39 AM6/18/08
to
Klaus Nowikow wrote:
> [...]

I just noticed an error in my post:

> @namespace url(http://my-namespace/example#);
> drawing {
> -moz-binding: url(example.xbl#example);
> display: -moz-box;
> }

should be:

@namespace url(http://my-namespace/example#);
example {
-moz-binding: url(example.xbl#example);
display: -moz-box;
}

That happened because I simplified the example and changed
some names. Sorry for that.

--
Klaus

Neil

unread,
Jun 18, 2008, 7:56:52 AM6/18/08
to
Klaus Nowikow wrote:

> Is there something I can implement in addition to make this work in my
> custom namespace?

I don't think so; if you use a custom namespace then all your elements
will be generic XML elements and won't have any useful properties
(class, id, event handler, etc.)

--
Warning: May contain traces of nuts.

Boris Zbarsky

unread,
Jun 18, 2008, 11:26:29 AM6/18/08
to
Klaus Nowikow wrote:
> When I don't use a namespace for the widget, this works. Is there
> something I can implement in addition to make this work in my custom
> namespace?

Your XBL binding constructor could go through the element's attributes, look for
on* ones, get the values, and use addEventListener accordingly. Then install
mutation listeners for those attributes so you can handle dynamic changes, etc.

Basically, duplicate the existing C++ on* code, more or less.

Depending on how transparent you want this to be, you'd also have to handle sets
of on* properties somehow. That might be harder.

-Boris

Klaus Nowikow

unread,
Jun 19, 2008, 10:59:45 AM6/19/08
to

I'm going to try that, thank you.

--
Klaus

0 new messages