How can I add a menu and sub menu items when right click on a file item visual studio solution explorer?
I have one menu and three sub menu items which will be displayed when I right click on a file in solution explorer like the below picture.
I tried using .vsct buttons but it will display on context menu and Iam unable to add sub menus
Authoring VSCT files is somewhat tricky; what you´ll need is a combination of a menu and buttons. First of all you need to reference the IDM_VS_CTXT_ITEMNODE group in your VSCT file.
<Group guid="guidCmdSet" id="grpIdMenuProjectItem" priority="0x0800">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_ITEMNODE" />
</Group>
Than you create a new menu and add it to that group...
<Menu guid="guidCmdSet" id="sampleMenu" type="Menu" priority="0x1000">
<Parent guid="guidCmdSet" id="grpIdMenuProjectItem" />
<CommandFlag>IconAndText</CommandFlag>
<Strings>
<ButtonText>Sample Menu</ButtonText>
<CommandName>Sample Menu</CommandName>
</Strings>
</Menu>
For the submenu items another group is required, which will be added to the menu...
<Group guid="guidCmdSet" id="sampleMenuGroup" priority="0x1000">
<Parent guid="guidCmdSet" id="sampleMenu"/>
</Group>
At least you define your submenu items using buttons and add them to the submenu group...
<Button guid="guidCmdSet" id="sampleMenuItem" priority="0x1000" type="Button">
<Parent guid="guidCmdSet" id="sampleMenuGroup"/>
<CommandFlag>TextOnly</CommandFlag>
<Strings>
<ButtonText>Sample Menu Item 1</ButtonText>
<CommandName>sampleMenuItem1</CommandName>
</Strings>
</Button>
Don´t forget to define all symbols, otherwise the resource won´t compile.
<IDSymbol name="grpIdMenuProjectItem" value="0x1020"/>
<IDSymbol name="sampleMenu" value="0x1021"/>
<IDSymbol name="sampleMenuGroup" value="0x1022"/>
<IDSymbol name="sampleMenuItem" value="0x1023"/>
And this is what you get...
Related
Im running 2016 Standalone Excel (32bit version). I've been building a custom ribbon and so far so good. The documentation is pretty fluid and well written. However, I cant find any way to include menu 'section titles' as seen below:
Specifically referencing section titles like in the picture (i.e., 'Cell size', 'Visibility' etc). I've seen other Add-Ins emulate this, unless they are COM Add-Ins. Here is the documentation I reference: https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx
Is it out of date? I've tried adding 'Menu with Title' to my project but that doesn't even work. I've also tried adding <labelControl /> , and the ribbon doesn't even load when the labelControl is within a Menu.
Additionally, my version of Excel won't even display a <dialogBoxLauncher> so I'm concerned some things just aren't compatabile with my Excel version to begin with. I'm following the documentation easily and everything else has worked just fine. I even have a editBox in the ribbon I use and don't run into any 91 errors with it. So I know it's not me.
Can anyone duplicate this with the provided API? My ribbon is structured with XML, so I've reduced as much error potential as possible, is that my problem? Should there be run-time code implemented specifically for section titles?
Short snippet of my setup
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="OnRibbonLoad">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="GroupTextTools" insertAfterMso="GroupFont" label="Text Tools">
<gallery id="textcase_gallery" label="Case Select" columns="1" size="large" imageMso="WordArtInsertDialogClassic" onAction="TextCase_SwitchCase" >
<item id="textcase_CapsButton" imageMso="TextAllCaps" label="Uppercase" screentip="Changes selected cells to all uppercase" />
<item id="textcase_ProperButton" label="Propercase" imageMso="ChangeCaseDialogClassic" screentip="Changes selected cells to proper case" />
<item id="textcase_LowerButton" label="Lowercase" imageMso="FontSizeDecrease" screentip="Changes selected cells to all small case" />
</gallery>
</group>
</tab>
<tab id="CustomTab" label="*removed*" insertAfterMso= "TabDeveloper">
<!--
GROUP A
-->
<group id="GroupFileOptions" label="File Options">
<button id="fileoptions_CloseButton" label="Close && Reopen" onAction="RunMacro" imageMso="SourceControlCheckIn" size="large" screentip="Saves Document, Closes && Reopens immediately"/>
<menu id="exportingmenu" label="Exporting" imageMso="FileCheckOut" size="large" screentip="Exporting Options">
<menu id="exportmenu_AsRange" label="As Range"> <!-- This is where I would like section Titles to be instead of another menu -->
<button id="exportmenu_range_CSVCButton" label="To CSV w/commas"/>
<button id="exportmenu_range_CSVSButton" label="To CSV w/spaces"/>
<button id="exportmenu_range_PDF" label="To PDF"/>
</menu>
<menu id="exportmenu_AsSheet" label="As Sheet"> <!--Goal is for this to be a section title, where I tried putting a <labelControl> -->
</menu>
</menu>
</group>
<!-- .... -->
</tab>
</tabs>
</ribbon>
</customUI>
After some trial and error, and an involuntary push from David Zemens by troubleshooting my errors, I've found that by cross referencing all the things I've tried with their Parent Elements, the only one that makes logical compiling sense is a <menuSeparator>, which just so happens to have a 'title' attribute. So by setting that you get a beautiful section title as shown:
<menuSeparator id="someID" title="Test title"/>
I managed to put a menu title only on a dynamicMenu via the getContent callback, which means the xml is defined in VBA as a piece of xml string, not in the customUI xml.
Most comprehensive documentation that I found so far on customUI interfaces is on https://msdn.microsoft.com/en-us/library/dd911038(v=office.12).aspx, however the references are pointing only to 2007. This link contains a much more extensive list of controls and options with extra controls for Access as well http://www.accessribbon.de/en/?Access_-_Ribbons:Ribbon_XML___Controls
I am new to programming but I tried to experiment with Excel ribbons. I am using the Custom UI Editor. I wanted to use the insertBefore and insertAfter controls to rearrange my custom buttons. If I do not use a unique namespace and insertAfterQ/insertBeforeQ at button level the order of buttons does not change, however, if I use it I cannot see the related macro (probably due to my namespace), therefore onAction will not do anything after clicking the buttons. I tried various combinations of idQ but I cannot make it work. The below example correctly executes just button 2 which is not in the namespace I specified.
A simple example:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" xmlns:x="MyNameSpace">
<ribbon>
<tabs>
<tab idQ="x:customTab" label="My Order Form" insertAfterMso="TabHome">
<group idQ="x:customGroup" label="My Order Form Tools">
<button idQ="x:customButton1" label="Clear" size="large" onAction="DeleteOrder" image="deleteorder" />
<button id="customButton2" label="Print" size="large" onAction="ResetOrder" image="resetorder" />
<button idQ="x:customButton3" label="Home" size="large" onAction="NewOrder" insertBeforeQ="x:customButton1" image="neworder" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Is there any way to make onAction work within the namespace? Or is there any other way? Many thanks, TS
Do you really need the namespace?
If you want to rearrange your own controls, just switch places in the xml:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="customTab" label="My Order Form" insertAfterMso="TabHome">
<group id="customGroup" label="My Order Form Tools">
<button id="customButton3" label="Home" size="large" onAction="NewOrder" image="neworder" />
<button id="customButton1" label="Clear" size="large" onAction="DeleteOrder" image="deleteorder" />
<button id="customButton2" label="Print" size="large" onAction="ResetOrder" image="resetorder" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
If you want to place your controls relative to built-in controls, use insertBeforeMso or insertAfterMso, like in your "customTab". From what I can tell you only need to use the namespace and idQ-ids if you combine controls from customUI-xml in different files.
I got a problem with creating a menu on a page contains tabs (tabgroups). When i insert the menu's code in a simple window, it works fine. But when i insert the same code on a tabgroup, no menu appears when running. I searched about this problem and it seems that the ancien version of SDK not supported menus on a tabgroups.
anyone can help me about this ?
this is my code:
<Alloy>
<TabGroup id="mainTabGroup">
<Tab id="tab3" onClick="getTodoList">
<Window id="readWin">
<Menu id="menu">
<MenuItem id="settingitem" onClick="doAction" title="Settings" showAsAction="Ti.Android.SHOW_AS_ACTION_ALWAYS">
<MenuItem id="calitem" onClick="doAction" title="Calendar" showAsAction="Ti.Android.SHOW_AS_ACTION_NEVER">
<MenuItem id="logitem" onClick="doAction" title="Logout" showAsAction="Ti.Android.SHOW_AS_ACTION_NEVER">
</Menu>
<TableView id="tableView" onClick="doSomething"/>
</Window>
</Tab>
</TabGroup>
</Alloy>
I think your showAsAction should be :
showAsAction="Ti.Android.SHOW_AS_ACTION_ALWAYS"
I found a lot of examples how to add custom tab with custom controls on the ribbon bar. But no one works for me. I got the custom tab, but button is always disabled.
There is my current version of code:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction
Id="CustomRibbonTab"
Location="CommandUI.Ribbon"
RegistrationId="101"
RegistrationType="List">
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition
Location="Ribbon.Tabs._children">
<Tab
Id="Ribbon.CustomTab"
Title="Custom Tab"
Description="Custom Tab !!!"
Sequence="701">
<Scaling
Id="Ribbon.CustomTab.Scaling">
<MaxSize
Id="Ribbon.CustomTab.MaxSize"
GroupId="Ribbon.CustomTab.CustomGroup"
Size="OneLargeTwoMedium"/>
<Scale
Id="Ribbon.CustomTab.Scaling.CustomTabScaling"
GroupId="Ribbon.CustomTab.CustomGroup"
Size="OneLargeTwoMedium" />
</Scaling>
<Groups Id="Ribbon.CustomTab.Groups">
<Group
Id="Ribbon.CustomTab.CustomGroup"
Description="Custom Group!"
Title="Custom Group"
Sequence="62"
Template="Ribbon.Templates.CustomTemplate">
<Controls Id="Ribbon.CustomTab.CustomGroup.Controls">
<Button
Id="Ribbon.CustomTab.CustomGroup.CustomButton"
Command="CustomTab.CustomButtonCommand"
Sequence="115"
Description=""
LabelText="Custom Button"
Image32by32="/_layouts/images/PPEOPLE.GIF"
TemplateAlias="cust1"/>
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.Templates._children">
<GroupTemplate Id="Ribbon.Templates.CustomTemplate">
<Layout
Title="OneLargeTwoMedium"
LayoutTitle="OneLargeTwoMedium">
<Section Alignment="Top" Type="OneRow">
<Row>
<ControlRef DisplayMode="Large" TemplateAlias="cust1" />
</Row>
</Section>
</Layout>
</GroupTemplate>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="CustomTab.CustomButtonCommand"
CommandAction="javascript:alert('Hello, world!');"
EnabledScript="javascript:return true;"/>
</CommandUIHandlers>
</CommandUIExtension>
</CustomAction>
</Elements>
I cleaned up the cache. I read about importance of EnabledScripts attribute in the CommandUIHandler. But I always have the same result:
Did anybody have the same issue? Please help!
I checked out a local custom action of mine, and the EnabledScript followed a different pattern:
EnabledScript="javascript:function JustReturnTrue()
{
return true
}
JustReturnTrue();"
If your item is showing up, but always disabled, I bet that's where the problem is.
I think the attribute is optional anyway, if I recall.
I had the same problem, I'm not sure if this is the proper solution, I'm a newbie. I removed the element from feature which scope was set to "Site", added another feature, set the scope to "Web", added my button item in this feature, saved, deployed, enabled the new feature from site features and it worked.
I develop MS Office add-in which extends ribbon in the following way:
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" loadImage="GetImage" onLoad="OnRibbonLoad">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="MyAppGroup" label="MyApp">
<splitButton id="SaveSplitButton" size="large" getEnabled="GetSaveButtonEnabled">
<menu id="SaveMenu" label="Save" itemSize="normal">
<button id="SaveMenuButton" image="save.png" label="Save to MyApp" onAction="SaveCommand" screentip="Saves the document" />
<button id="SaveAsMenuButton" label="Save to MyApp As" onAction="SaveAsCommand" screentip="Saves the document under a new name" getEnabled="GetSaveAsButtonEnabled"/>
</menu>
</splitButton>
</group>
</tab>
</tabs>
When I go to File > Options > Customize Ribbon (in any Office application) I expect to see "MyApp" group in "Home" tab with one "Save" menu having only one "Save to MyApp" and one "Save to MyApp As" subitems in it. But instead I get "Save to MyApp" item doubled under the "Save" menu.
I know that if I move "SaveMenuButton" from menu right into the splitButton then I'll get rid of that doubling but I need these two options in the menu.
Experts! Please help!