- From: Robin Berjon <robin@w3.org>
- Date: Mon, 23 Mar 2015 10:45:39 +0100
- To: Shane McCarron <shane@aptest.com>, "spec-prod@w3.org Prod" <spec-prod@w3.org>
Hi Shane, On 22/03/2015 22:22 , Shane McCarron wrote: > Sorry, I know I asked something like this before, but I have hit a > wall. What I want to do is add a menu item to the respec UI. > > When I look in the profile-w3c.common.js file, I see pretty clearly how > to add a handler assuming I have a handle to the ui object. But since > that object is somewhat buried, it is unclear to me how I can get at it > in a way that won't be brittle. Is this for a specific draft, or something you'd like to add across the board for all ReSpec documents? If the latter, then just add it in the same way as the others here: https://github.com/w3c/respec/blob/develop/js/profile-w3c-common.js#L59 Otherwise, you will need to write something along the lines of: define(["core/ui"], function (ui) { ui.addCommand("Do Stuff", "ui/stuff-doer", "Ctrl+Shift+Alt-D"); }); And then have a module under ui/stuff.doer.js that's implemented in the same way as the others. > When do I want to get at it? Well, the easiest way would be in an event > handler function: > > respecEvents.sub('end-all', function() {...}); A quick look at the code makes me think it would work pretty much at any moment, at least after the processing has started. So yeah, end-all seems like as good a place as any. > So at the end of respec processing, I add my menu and viola. Any ideas? PS: it's a common mistake, but I feel compelled to point out it's "voilĂ ", not "viola". The latter means "raped"; probably not what one intends to convey! -- Robin Berjon - http://berjon.com/ - @robinberjon
Received on Monday, 23 March 2015 09:45:43 UTC