[Project_owners] 'command' attribute breaking menuitems?

Neil neil at parkwaycc.co.uk
Mon Nov 7 00:42:32 EST 2005


Andy McDonald wrote:

> It seems that a 'command' attribute on a <menuitem/> prevents that 
> menuitem from being selected in a dropdown (i.e. <menulist>). 

Right, that's an abuse of a menulist - you shouldn't be adding command 
handlers to the menuitem. But if you insist...

When an element, such as a key, toolbarbutton or menuitem, prepares to 
generate a command event, it first checks for a command attribute on the 
element, and if it finds an element with that id, it targets the command 
event on that element instead. This means that you only have to declare 
one event handler (note that the similar broadcaster works by creating 
copies of the event handler, thus consuming memory). But it also results 
in the effect you describe. Note that there is no way of knowing what 
the initiating element was.

In fact this effect can be utilised to your advantage in the case that 
you have menuitems that you don't want to be selected such as a 
Customise List... option ;-)


More information about the Project_owners mailing list