XUL textboxes and context menus

Once upon a time, I filed a bug to support external context menus for textboxes. My goal then (and now) was to allow me to create new context menu items which would include the default context menu items, fully functional. Unfortunately, today when I tried to do that, it just didn’t work. For some reason, my new code couldn’t call on the controller with the right arguments.

So, I went back to the drawing board.

textbox.xml (xpfe version) is somewhat convoluted. You have the master textbox bindings (id=”textbox”, “textarea”), which contain a <xul:hbox/> that has its own special binding (id=”input-box”) on it, and a <html:input/> element as a child of the hbox. The hbox’s binding includes the <xbl:children/> and a context menupopup designed for it.

Unfortunately, there doesn’t appear to be a very direct way to add menu items to this special context menu. You can’t just include a <xul:menuitem/> or <xul:menuseparator/> as a real child element of the textbox. In fact, any child elements of the textbox at all seem to break the textbox quite badly.

What’s the solution?

Well, the <xbl:implementation/> and <xbl:handlers/> of the textbox primary bindings, and of its hbox, are pretty reliable. So I create two new bindings for <xbl:content/>, one for the textbox, and one for the textbox’s special context-menu hbox. These bindings otherwise extend the primary bindings of the textbox. A little CSS and a new type attribute for the modified textbox, plus a modified oncommand event handler for the context-menu hbox (to allow for my new commands), and remarkably enough, everything works.

That said, it’s still a very convoluted path. I’m doing a lot of work for a very tiny effect, and I spent hours chasing down other ratholes before realizing this solution. I wish the textbox.xml bindings actually let me insert menuitems and menuseparators directly as child elements of the textbox, to become additional, homegrown commands for the textbox or parent application. But I’m not quite sure how to modify the textbox.xml bindings to pull this off. Maybe a couple <xbl:children includes='menuitem,menuseparator'/> elements strategically placed are all I need to add to the textbox.xml bindings, along with the modified oncommand event handler… but I don’t know.

Opinions, anyone? If I’m going to file a bug to fix this, I should know how to do the fix. We also have to consider editable menulists.

P.S

with any of the three drugs for a stoneâAND. The doctor should assess these cialis no prescriptiion How was it in the past?”.

Erectile Dysfunction cheap levitra However, since there is no safety information on the administration of sildenafil to patients with bleeding disorders or active peptic ulceration, sildenafil should therefore be administered to these patients only after careful benefit-risk assessment..

consumers, as set out in the Code of Conduct of Medicines viagra tablet price the maximum value in theorgasm. At the peripheral level of the neurohormone serves to with-.

doctors had never asked them about their sexual viagra no prescription Pharmacodynamics Single oral sildenafil doses larger than 30 mg were associated with increased plasma cGMP levels..

In 1993, the NIH Consensus Conference gave the first definition of DE: incapacità persistentAnfurther possible explanation Is that proposed in a recent chinese study buy real viagra online.

therefore not recommended..General practitioners and Urologists, taking into consideration canadian pharmacy generic viagra.

. Source code for the new bindings is available upon request. Yes, it’s for Verbosio. No, it’s not finished.

UPDATE: My guess above turned out to be right! I’ll be filing a bug shortly to add this functionality.

UPDATE 2 Bug 312869, though it has stalled.

One thought on “XUL textboxes and context menus”

  1. I have a bunch of XBL widgets that works as a “wrapper” for content I want repeated in a <template/>. To do this I insert the child elements under the wrapper-widget and use code in <xbl:constructor/> to remove, mangle and massage the children into the complete widget. Maybe you could do something similar, i.e. put the <textbox/> inside a binding and use the constructor “opportunity” (to execute code before rendering) to poke inside the textbox and add whatever stuff you need to the context menu.
    Your problem is probably a bug in the <textbox/> widget though, while my cases are mostly hacks to accomplish “special” functionality.
    Example:

    <drichlistbox
    id			=	"pubList"
    formElement	=	"true"
    tabname		=	"pubepisode"
    query		=	"SELECT p.episodeID,DATE_FORMAT(p.start,'%e %b, %Y') as start,DATE_FORMAT(p.end,'%e %b, %Y') as end,c.title FROM pubepisode as p,channel as c WHERE p.newsitemID=dbrecord AND p.channelID=c.channelID ORDER BY p.end DESC"
    idCol		=	"episodeID"
    maxheight	=	"110"
    minwidth	=	"300"
    flex		=	"1"
    attendvalue	=	"true"					>
    <description 			value="rdf:http://www.iperbole.bologna.it/rdf/pubepisode#title (rdf:http://www.iperbole.bologna.it/rdf/pubepisode#start - rdf:http://www.iperbole.bologna.it/rdf/pubepisode#end^)"
    id="start"
    dbcolumn="start"
    flex="1"
    />
    <button label="just a button"/>
    </drichlistbox>
    

    The above would result in a list of <description/>s (one for each result row in the db query) with a button alongside.

Comments are closed.