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

extends=xul:button

0 views
Skip to first unread message

cani...@gmail.com

unread,
Dec 29, 2007, 12:44:51 PM12/29/07
to
What's the difference between using extends on another binding (e.g.
extends="bindings.xml#foo") and using it on an element type (e.g.
extends="xul:button")?

This is in the toolkit binding for XUL scrollbars in Fx2

http://mxr.mozilla.org/mozilla1.8/source/toolkit/content/widgets/scrollbar.xml#8

Thanks.

Neil

unread,
Dec 29, 2007, 7:00:11 PM12/29/07
to
cani...@gmail.com wrote:

>What's the difference between using extends on another binding (e.g. extends="bindings.xml#foo") and using it on an element type (e.g. extends="xul:button")?
>
>

Some XUL elements automagically get special processing. For instance, in
the case of a button, one effect is that clicking an enabled button
generates a command event. To get that behaviour in an arbitrary widget
you need to use extends="xul:button".

The other form of extends simply refers to another XBL binding; all the
properties and methods are inherited in much the same way as any other
object-oriented system.

Note that occasionally you want to inherit the properties and methods of
another binding, but the internal behaviour of a specific XUL element.
<toolbarbutton type="menu"> is one such example. In such a case you
would use display="xul:menu" extends="#toolbarbutton-base".

--
Warning: May contain traces of nuts.

Boris Zbarsky

unread,
Dec 29, 2007, 11:19:40 PM12/29/07
to
Neil wrote:
> Some XUL elements automagically get special processing. For instance, in
> the case of a button, one effect is that clicking an enabled button
> generates a command event. To get that behaviour in an arbitrary widget
> you need to use extends="xul:button".

Note that this might stop working (possibly in the 1.9 timeframe).

-Boris

Brendan Eich

unread,
Dec 30, 2007, 12:05:56 AM12/30/07
to Boris Zbarsky, dev-te...@lists.mozilla.org

Really? How come?

/be


Boris Zbarsky

unread,
Dec 30, 2007, 9:28:46 AM12/30/07
to
Brendan Eich wrote:
>> Note that this might stop working (possibly in the 1.9 timeframe).
>
> Really? How come?

https://bugzilla.mozilla.org/show_bug.cgi?id=378518

-Boris

cani...@gmail.com

unread,
Jan 27, 2008, 9:59:37 PM1/27/08
to
On Dec 29 2007, 6:00 pm, Neil <n...@parkwaycc.co.uk> wrote:
> Some XUL elements automagically get special processing. For instance, in
> the case of a button, one effect is that clicking an enabled button
> generates a command event. To get that behaviour in an arbitrary widget
> you need to use extends="xul:button".

Thanks Neil.

I'm trying to understand this in detail so I can extend these into new
types or create something similar.

1. Which behaviors are added with display=xul:menu?

2. Which behaviors are added with display=xul:button?

3. Can you put two display attributes on the same binding? E.g., could
you say toolbarbutton.xml#menu display="xul:menu" display="xul:button"
extends="something.xml#some_id ?

4. If I remove display="xul:menu" from toolbarbutton.xml#menu, then
the bookmarks toolbar chevron doesn't open any more and doesn't appear
to get open="true" any more either, so that must be one of the added
behaviors?

5. Where/how is open="true" added to toolbarbutton[type="menu"]? This
code in button.xml#button-base seems related, although it just
provides setters and getters and doesn't actually set a value:

http://mxr.mozilla.org/mozilla/source/toolkit/content/widgets/button.xml#30

There's also this code, which sets values for open (but doesn't seem
to be in the extends chain for a toolbarbutton[type="menu"]):

http://mxr.mozilla.org/mozilla/source/toolkit/content/widgets/button.xml#236

I'm still digging into this, but any pointers would be a big help.

Neil Deakin

unread,
Jan 27, 2008, 11:35:44 PM1/27/08
to
cani...@gmail.com wrote:

> 1. Which behaviors are added with display=xul:menu?
>
> 2. Which behaviors are added with display=xul:button?
>

The 'display' causes a different layout object (called a frame in
Mozilla terminology) to be created for the element. For 'xul:menu', an
nsMenuFrame is created and for a 'xul:button', an nsButtonBoxFrame is
created. The display attribute of 'xul:menu' effectively means for
certain purposes, treat this element as if it was a xul <menu> element.

A button frame adds the behaviour of firing the command event when the
button is activated.

A menu frame adds behaviour which highlights the menu, as well as opens
and closes the menu's popup when various events occur, all of which vary
for menus on menubars, menus not on menubars, submenus, and to account
for platform differences. In addition, the menu is responsible for
positioning the popup during a layout. This is the normal behaviour of
the <menu> element.

> 3. Can you put two display attributes on the same binding? E.g., could
> you say toolbarbutton.xml#menu display="xul:menu" display="xul:button"
> extends="something.xml#some_id ?
>

No.

> 4. If I remove display="xul:menu" from toolbarbutton.xml#menu, then
> the bookmarks toolbar chevron doesn't open any more and doesn't appear
> to get open="true" any more either, so that must be one of the added
> behaviors?

Indeed, as the toolbarbutton is no longer a menu.

> 5. Where/how is open="true" added to toolbarbutton[type="menu"]?

In nsMenuFrame.cpp

Neil

cani...@gmail.com

unread,
Jan 28, 2008, 3:17:24 AM1/28/08
to
On Jan 27, 10:35 pm, Neil Deakin <enndea...@sympatico.ca> wrote:
> > 3. Can you put two display attributes on the same binding? E.g., could
> > you say toolbarbutton.xml#menu display="xul:menu" display="xul:button"
> > extends="something.xml#some_id ?
>
> No.

Great, thank you.

How does this work in the case of toolbarbutton[type="menu"], where
toolbarbutton.xml#menu, having display="xul:menu", extends
toolbarbutton.xml#toolbarbutton, having display="xul:button"? Does
the bound element still get the command event behavior of the button,
or does display="xul:menu" override and replace display="xul:button"?

Neil

unread,
Jan 28, 2008, 10:01:50 AM1/28/08
to
cani...@gmail.com wrote:

>How does this work in the case of toolbarbutton[type="menu"], where toolbarbutton.xml#menu, having display="xul:menu", extends toolbarbutton.xml#toolbarbutton, having display="xul:button"? Does the bound element still get the command event behavior of the button, or does display="xul:menu" override and replace display="xul:button"?
>
>

No, the display="xul:menu" completely replaces the effect of the
display="xul:button".

0 new messages