XUL: How do you create a nested menupopup inside a statusbarpanel (with statusbarpanel-menu-iconic) - xul

In XUL you can use create a status bar panel icon, similar to the ones used by Firebug and Greasemonkey, with the <statusbarpanel> tag. If you set the right class, you can throw a <menupop> inside, and then have a pop-up menu when the user clicks on the icon, like so ...
<statusbarpanel class="statusbarpanel-menu-iconic"
src="chrome://YourExtension/content/icon.png">
<menupopup>
<menuitem label="whatever" oncommand="doSomething();">
<menuitem label="whatever else" oncommand="doSomethingElse();">
</menupopup>
</statusbarpanel>
Now, with other pop-up menus, you can nest a series of menus using the menu tag:
<statusbarpanel class="statusbarpanel-menu-iconic"
src="chrome://YourExtension/content/icon.png">
<menu value="Old">
<menupopup>
<menuitem label="whatever" oncommand="doSomething();">
<menuitem label="whatever else" oncommand="doSomethingElse();">
</menupopup>
</menu>
<menu value="New>
<menupopup>
<menuitem label="yet another" oncommand="doYetAnotherSomething();">
</menupopup>
</menu>
</statusbarpanel>
but the above code doesn't actually work, because <statusbarpanel> won't allow a <menu> child (well, it will allow it, but not create the desired effect).
So, what I was wondering was ... is there any way I can make a status bar panel icon-triggered menu with multiple layers of menu items?
* EDIT *
Since I can't post this in the comment to the answer (and get syntax coloring and such), here's what finally worked for me (thanks Sathish!):
<statusbarpanel class="statusbarpanel-menu-iconic"
src="chrome://YourExtension/content/icon.png" popup="stausBarPanelMenu">
</statusbarpanel>
<popup id="statusBarPanelMenu" position="start_before">
<menu value="Old">
<menupopup>
<menuitem label="whatever" oncommand="doSomething();">
<menuitem label="whatever else" oncommand="doSomethingElse();">
</menupopup>
</menu>
<menu value="New>
<menupopup>
<menuitem label="yet another" oncommand="doYetAnotherSomething();">
</menupopup>
</menu>
</popop>
Oh, and as a side note to any XUL devs who might read this: you should really eliminate the "menupopup inside a statusbarpanel" style of pop-up. The style that answered this question is just as easy to learn/use, significantly more powerful, and it relies on the same popup mechanisms that can be used with the other XUL elements. This whole "menupopup inside a statusbarpanel" this is just a confusing, un-needed, anomaly.

Try this:
create a popup element like this:
<popup ... >
<menu ... >
<menupopup ... >
<menuitem ... >
</menupopup ... >
</menu>
</popup>
assign the id of popup element to the oncontextmenu attribute or show it dynamically using onclick event of the statusbarpanel element.

Related

Orienting Controls on Ribbon.xaml

I have a Visio Addin that I have been adding controls to. I have a simple problem but I'm struggling to find an answer to.
I have these four controls in a group. I just added a new one called Query Preference.
I would like to align this in such a way where Modern Shapes shows up under Query Preference in the highlighted area below.
The Xaml code for this group is as follows.
I'm fairly certain there is alignment property, but I can't find for the group tag to do what I want.
Does anyone have experience with this?
<group id="connectionGroup" label="Manage">
<button id="authenticate" label="Configure Connection" size="normal" getImage="GetImage" onAction="OnAction" getEnabled="GetEnabled" supertip="Set the server and authentication information"/>
<button id="stencil" label="Generate Stencil" size="normal" getImage="GetImage" onAction="OnAction" getEnabled="GetEnabled" supertip="Generate a new stencil using the metamodel of the current server"/>
<menu id="modernClassicShapesDropdown" getLabel="GetShapeStyleLabel" getImage="GetShapeStyleImage" getEnabled="GetEnabled" supertip="Determine how new shapes will be rendered">
<button id="modernShapes" label="Modern Shapes" getImage="GetImage" onAction="OnShapeStyleAction"/>
<button id="classicShapes" label="Classic Shapes" getImage="GetImage" onAction="OnShapeStyleAction"/>
</menu>
<menu id="queryPreference" label="Query Preference" getImage="GetImage" getEnabled="GetEnabled" supertip="Determines how much Shape data is queried.">
<button id="Low" label="Low" onAction="OnQueryPreferenceAction" supertip="Only component name and description are queried and available in shape data. Select this option for fastest drawing time."/>
<button id="Medium" label="Medium" onAction="OnQueryPreferenceAction" supertip="Only native component properties are queried. Calculated properties are not initially available in shape data."/>
<button id="High" label="High" onAction="OnQueryPreferenceAction" supertip="All component properties are queried and available in shape data, including calculated properties."/>
</menu>
</group>
Why not just move the "Modern Shapes" menu item to after "Query Preference" and then insert a blank line:
<button id="junk42" label=" " />

Transparent context menu item during Thunderbird addon development

Currently i am developing a context menu addon for Thunderbird 3*. I am trying to add my own Submenu items as part of existing Thunderbird Context menu for mail content.
With the following XUL:
<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://elane/content/expoverlay.js"/>
<popup id="mailContext">
<menu id="elMenu" label="submenu 1">
<popup id="elMenu-popup">
<menuitem id="openBing"
label="Sub Menu Item 1"
oncommand="openURL('https://bing.com')"/>
<menuitem id="openGoogle"
label="Sub Menu Item 2"
oncommand="openURL('https://google.com')"/>
</popup>
</menu>
</popup>
</overlay>
The newly added Context menu item and submenu items are having transparent background:
Can anyone help me with the reason behind this and possible fix?
Change <popup id="elMenu-popup"> and corresponding </popup> to <menupopup id="elMenu-popup"> and </menupopup>

Add Event to UI button click

I have created a custom ribbon in Microsoft Word but I am having issues attaching events to the buttons found in a ribbon. Below is my code:
UI XML:
<mso:cmd app="Word" dt="1" />
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true" >
<tabs>
<tab id="CustomTab" label="MyTasks" >
<group id="Group1" label="Details Labels">
<menu id="Menu1" label="Details" size="large">
<menu id="Menu21" label="Dates">
<button id="my_date" onAction="foo_eventhandler" label="Some Date" />
</menu>
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I then have the following VBA code in Modules/NewMacros VBA code:
Sub foo_eventhandler(control As IRibbonControl)
End Sub
NOTE:
I import the XML by opening Word-->going to File-->Options-->Customize Ribbon-->Import/Export. I then select my XML file and import it.
When this code is run, though, I get the error "Argument Not Optional". If I run the same code without the "control As IRibbonControl" it's fine but I need to be able to get the Sender object. Anyone have any suggestions?
jason
I think you are running into problems because you are importing the XML code via Options -> Customize Ribbon ->Import/Export. This method is really for general users who wish, for example, to never see the Page Layout tab and have it hidden. They can export their custom ribbon and import it onto new machines for the same layout.
For developers a better method is use the most excellent CustomUIEditor for Word and Excel. http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx
The steps you need to take are to create your normal macro enabled Word template (the .dotm) file and save it. Then open that file up in the CustomUIEditor and paste you XML (minus the first line). I've expanded your XML code with another button and I've added the tag to the XML so the VBA knows which button is being pressed.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false" >
<tabs>
<tab id="CustomTab" label="MyTasks" >
<group id="Group1" label="Details Labels">
<menu id="Menu1" label="Details" size="large">
<menu id="Menu21" label="Dates">
<button id="my_date_1" onAction="foo_eventhandler" label="Some Date" tag="Date1" />
<button id="my_date_2" onAction="foo_eventhandler" label="Some Other Date" tag="Date2" />
</menu>
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I generally put my Ribbon code in a Ribbon module. In your callback code you just need to use the .Tag property of the inputted control variable to know which button is pressed which you'll see corresponds to the tag in the XML. ie:
Sub foo_eventhandler(control As IRibbonControl)
MsgBox "Hooray! for " & control.Tag
End Sub

Dynamic menu contribution in plugin.xml

In my plugin.xml I have
<menuContribution
allPopups="false"
locationURI="menu:arm.views.funblocks?after=additions">
<menu
icon="icons/fblock.gif"
id="arm.views.funblocks.create"
label="%arm.views.funblocks.create">
<dynamic class="ru.focusmedia.odp.arm.funblocks.navigator.admin.CreateFunBlockContrib"
id="arm.views.funblocks.create.menuitems">
</dynamic>
</menu>
<command
commandId="org.eclipse.ui.edit.delete"
style="push">
</command>
</menuContribution>
and this works fine. However, if I replace menu: with toolbar: in locationURI, only the delete command shows up, but not the menu. I've also tried replacing <menu> element with <toolbar>, but with no result. How can I do this?
You cannot add a menu or toolbar to a toolbar.
You can make the content of a menu of toolbar completely dynamic by using the class attribute of the menuContribution element.

Context Menus and NavigateTo in Blend / SketchFlow

Hoping this will be a simple one, in Sketchflow i'm trying to wire up a context menu to navigate to another page.
I've created the context menu, added a menu item, right clicked the mneu item in the Objects and Timeline panel and selected navigateto. When i run it, the menu comes up but when i click on the menu item it doesn't do anything.
I previously had the NavigateTo working when left clicking on another object, so the screens / connections are all in place.
This is the xaml that was generated:
<ContextMenu>
<MenuItem Header="Edit">
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDown">
<pb:NavigateToScreenAction TargetScreen="SomeScreen.Screen_3_2"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</MenuItem>
</ContextMenu>
This xaml works for the scenario I think you are trying to achieve:
<Button Content="Button">
<Button.ContextMenu>
<ContextMenu>
<MenuItem Header="Next">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<pb:NavigateToScreenAction TargetScreen="WpfPrototype3Screens.Screen_2"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</MenuItem>
</ContextMenu>
</Button.ContextMenu>
</Button>
As long as the path for the TargetScreen is correct, just change the EventName to "Click" and it will work. "Click" handles the "MouseDown" event.