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.
>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.
Note that this might stop working (possibly in the 1.9 timeframe).
-Boris
Really? How come?
/be
https://bugzilla.mozilla.org/show_bug.cgi?id=378518
-Boris
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.
> 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
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"?
>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".