There are two bonus properties, LongDescription and ToolTipImage, in the RibbonItem. They are optional and will be shown when the mouse hovers over the ribbon item for a few seconds. Here is an example:
Every ribbon button or member is derived from the RibbonItem so the two advanced properties are inherited down like:
Autodesk.Revit.UI.RibbonItem
Autodesk.Revit.UI.ComboBox
Autodesk.Revit.UI.ComboBoxMember
Autodesk.Revit.UI.RadioButtonGroup
Autodesk.Revit.UI.RibbonButton
Autodesk.Revit.UI.PulldownButton
Autodesk.Revit.UI.SplitButton
Autodesk.Revit.UI.PushButton
Autodesk.Revit.UI.ToggleButton
Autodesk.Revit.UI.TextBox
Though every ribbon item has the two properties and they can be set as any strings or images we like, they do not apply to the SplitButton or the RadioButtonGroup. The SplitButton will always show the long description and the tooltip image of the current PushButton, and the RadioButtonGroup has no tooltip image or long description at all as it cannot be highlighted.
The following is some example code to set the two properties for various ribbon items as shown in the hierarchy branch:
private void LongDescriptionAndToolTipImageOfVariousRibbonItem(RibbonPanel panel)
{
string assemFullName = Assembly.GetExecutingAssembly().Location;
string assemPath = Path.GetDirectoryName(assemFullName);
ComboBoxData CB1Data = new ComboBoxData("Combo1");
//CB1Data.Text = "The ComboBoxData does not support it!";
Autodesk.Revit.UI.ComboBox combo1 = panel.AddItem(CB1Data) as Autodesk.Revit.UI.ComboBox;
combo1.ItemText = "The text for the ComboBox(Data) can only be set here!";
combo1.ToolTip = "The tooltip for the ComboBox #1";
combo1.LongDescription = "<p>Hello,</p><p>I am ComboBox #1.</p><p>Regards,</p>";
combo1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
ComboBoxMemberData cb1Mem1Data = new ComboBoxMemberData("com1Mem1", "Combo1 item 1");
//cb1Mem1Data.Text = "Do not bother to set it again!";
ComboBoxMember cb1Mem1 = combo1.AddItem(cb1Mem1Data);
//cb1Mem1.ItemText = "Do not bother to set it again!";
cb1Mem1.ToolTip = "The tooltip for the ComBoxMember #1";
cb1Mem1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
cb1Mem1.LongDescription = "<p>Hello,</p><p>I am #1 ComboBoxMember of the ComboBox #1.</p><p>Regards,</p>";
cb1Mem1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
RadioButtonGroupData rbg1Data = new RadioButtonGroupData("RadioButtonGroup1");
RadioButtonGroup rbGroup1 = panel.AddItem(rbg1Data) as RadioButtonGroup;
//rbg1Data.Text = "The RadioButtonGroupData does not support it!";
rbGroup1.ItemText = "No chance to show up!";
rbGroup1.ToolTip = "No chance to show up!";
rbGroup1.LongDescription = "<p>Hello,</p><p>I am RadioButtonGroup #1.</p><p>Regards,</p>";
rbGroup1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
ToggleButtonData rb1Mem1Data = new ToggleButtonData("rbg1Mem1", "ToggleButton #1", assemFullName, "RevitAddinCSProject.ExtCmd1");
//rb1Mem1Data.Text = "Do not bother to set the Text again as it has to be specified in the constructor anyway!";
ToggleButton rb1Mem1 = rbGroup1.AddItem(rb1Mem1Data);
//rb1Mem1.ItemText = "Do not bother to set the (Item)Text again here!";
rb1Mem1.ToolTip = "The tooltip for the ToggleButton #1 in RadioButtonGroup";
rb1Mem1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
rb1Mem1.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_32x32.bmp");
rb1Mem1.LongDescription = "<p>Hello,</p><p>I am #1 ToggleButton of the RadioButtonGroup #1.</p><p>Regards,</p>";
rb1Mem1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
PulldownButtonData PBgroup1Data = new PulldownButtonData("PulldownGroup1", "Pulldown Group 1");
//PBgroup1Data.Text = "Do not bother to set it again!";
PBgroup1Data.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
PBgroup1Data.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_32x32.bmp");
PulldownButton PBgroup1 = panel.AddItem(PBgroup1Data) as PulldownButton;
//PBgroup1.ItemText = "Do not bother to set the (Item)Text again here!";
PBgroup1.ToolTip = "The tooltip for the PulldownButton #1";
PBgroup1.LongDescription = "<p>Hello,</p><p>I am PulldownButton #1.</p><p>Regards,</p>";
PBgroup1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
PushButtonData PBgroup1item1Data = new PushButtonData("PBgroup1item1", "Push Button 1 in PulldownButton", AssemblyFullName, "RevitAddinCSProject.ExtCmd1");
//PBgroup1item1Data.Text = "Do not bother to set the Text again as it has to be specified in the constructor anyway!";
PushButton PBgroup1item1 = PBgroup1.AddPushButton(PBgroup1item1Data) as PushButton;
//PBgroup1item1.ItemText = "Do not bother to set the (Item)Text again here!";
PBgroup1item1.ToolTip = "The tooltip for the PushButton #1 in PulldownButton";
PBgroup1item1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
PBgroup1item1.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_32x32.bmp");
PBgroup1item1.LongDescription = "<p>Hello,</p><p>I am #1 PushButton of the PulldownButton #1.</p><p>Regards,</p>";
PBgroup1item1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
SplitButtonData SBgroup1Data = new SplitButtonData("SplitGroup1", "No chance to show up!");
//SBgroup1Data.Text = "Do not bother to set it again. It does not have a chance to show up anyway!";
SplitButton SBgroup1 = panel.AddItem(SBgroup1Data) as SplitButton;
//SBgroup1.ItemText = "Do not bother to set it again. It does not have a chance to show up anyway!";
SBgroup1.ToolTip = "The tooltip for the PushButton #1";
SBgroup1.LongDescription = "<p>Hello,</p><p>I am SplitButton #1.</p><p>Regards,</p>";
SBgroup1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
PushButtonData SBgroup1item1Data = new PushButtonData("SBgroup1item1", "Push Button 1 in SplitButton", AssemblyFullName, "RevitAddinCSProject.ExtCmd1");
//SBgroup1item1Data.Text = "Do not bother to set the Text again as it has to be specified in the constructor anyway!";
PushButton SBgroup1item1 = SBgroup1.AddPushButton(SBgroup1item1Data) as PushButton;
//SBgroup1item1.ItemText = "Do not bother to set the (Item)Text again here!";
SBgroup1item1.ToolTip = "The tooltip for the PushButton #1 in SplitButton";
SBgroup1item1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_16x16.bmp");
SBgroup1item1.LargeImage = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item1_32x32.bmp");
SBgroup1item1.LongDescription = "<p>Hello,</p><p>I am #1 PushButton of the SplitButton #1.</p><p>Regards,</p>";
SBgroup1item1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
TextBoxData nogroupitem1Data = new TextBoxData("nogroupitem1");
//nogroupitem1Data.Text = "Somthing"; // No such a thing!
Autodesk.Revit.UI.TextBox nogroupitem1 = panel.AddItem(nogroupitem1Data) as Autodesk.Revit.UI.TextBox;
nogroupitem1.Value = "Hello";
//nogroupitem1.ItemText = "Will cause an exception!";
nogroupitem1.ToolTip = "Tooltip of the TexBox in no group";
nogroupitem1.Image = BmpImageSource("RevitAddinCSProject.Resources.Embedded_Item2_16x16.bmp");
nogroupitem1.ShowImageAsButton = true;
nogroupitem1.EnterPressed += CallbackOfTextBox;
nogroupitem1.LongDescription = "<p>Hello,</p><p>I am #1 TextBox.</p><p>Regards,</p>";
nogroupitem1.ToolTipImage = new BitmapImage(new Uri(Path.Combine(AssemblyPath, "Buddies.bmp"), UriKind.Absolute));
}
If the following code is added to somewhere in the OnStartup method of an IExternalApplication interface implementation:
RibbonPanel panel = _cachedUiCtrApp.CreateRibbonPanel(Guid.NewGuid().ToString());
panel.Enabled = true;
panel.Visible = true;
panel.Name = "ABC_APP3_PNL1";
panel.Title = "LongDescription And ToolTipImage";
LongDescriptionAndToolTipImageOfVariousRibbonItem(panel);
The long description (LongDescription) and the tooltip image (ToolTipImage) will show up when applicable. Here are some more examples:
As a side product, the code example also demonstrate the usage of ItemText and Name properties of RibbonItem and the usage of Text and Name of RibbonItemData and its derivatives along with their constructors.
The RibbonItemData does not have a Text property but some of its derivatives do, such as ComboBoxMemberData, ButtonData, and ToggleButtonData. Every ribbon button or member has the ItemText inherited from the RibbonItem and it does pretty the same thing as the Text does in their corresponding data class if applicable. Most of times, it does not harm if the ItemText is set accidentally in the RibbonItem even if its data pair class does not support a Text at all. However, the TextBox is exceptional, if its ItemText property is explicitly set, an exception saying ‘ItemText property is not supported by TextBox’ will be thrown out when Revit is trying to create the TextBox and all followed ribbon creation code will be discarded.
The RevitAddinWizard currently does not support the two bonus properties, LongDescription and ToolTipImage. In the future when it does, it will take these into account.
Links to some related articles:
Ribbon of Revit API - PushButton And TextBox
Use Ribbon Creator of RevitAddCoder to Create PushButton And Separator
Use Ribbon Creator of RevitAddCoder to Create TextBox
Ribbon of Revit API - ComboBox And ComboBoxMember
Use Ribbon Creator of RevitAddCoder to Create ComboBox And ComboBoxMember
Ribbon of Revit API - PulldownButton And SplitButton
Use Ribbon Creator of RevitAddCoder to Create PulldownButton And PushButton
Use Ribbon Creator of RevitAddCoder to Create SplitButton And PushButton
Ribbon of Revit API - RadioButtonGroup And ToggleButton
Use Ribbon Creator of RevitAddCoder to Create RadioButtonGroup And ToggleButton
Ribbon of Revit API - Stacked Group And AddStackedItems
Ribbon of Revit API - Stacked Group And PulldownButton
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And PushButton Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And TextBox Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And PulldownButton Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And ComboBox Items
Use Ribbon Creator of RevitAddCoder to Create Stacked Group And Various Items
Ribbon of Revit API - Slideout
Use Ribbon Creator of RevitAddCoder to Create Slideout And Various Buttons
Ribbon of Revit API - Manipulate Panels Created by Other Addins
Access Ribbons Created by Ribbon Creator From Another Addin
Update Ribbons Created by Ribbon Creator From Another Addin
Use Ribbon Creator of RevitAddCoder to Create a Comprehensive Ribbon Panel
Ribbon of Revit API - Title And Name of Panels
Ribbon of Revit API - Text And Name of RibbonItem
Ribbon of Revit API - LongDescription And TooltipImage of RibbonItem
Recent Comments