I would like to add a tooltip to an EditorButton that I added to the UltraDateTimeEditor in the ButtonsRight collection.
editor.ButtonsRight.Add(new EditorButton("btnRelative"));
How can get a tooltip for just that editor button and not the entire date time editor?
Thanks!
I was able to hack this out but I couldn't find a way to make the tooltip disappear when the mouse leaves the button. I set the AutoPopDelay to 2 sec. to work around this, so at least it goes away after a certain amount of time. You might want to submit a feature request for a ToolTipText property to be added to the EditorButton class.
Example:EditorButton button = new EditorButton();this.textEditor.ButtonsRight.Add( button );this.textEditor.CreationFilter = new CreationFilter();
private class CreationFilter : IUIElementCreationFilter{ void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { ButtonUIElementBase buttonElement = parent as ButtonUIElementBase; if ( buttonElement != null ) { ToolTipProviderUIElement tooltipElement = new ToolTipProviderUIElement( buttonElement ); tooltipElement.Rect = buttonElement.Rect; buttonElement.ChildElements.Add( tooltipElement ); } }
bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { return false; }}
private class ToolTipProviderUIElement : UIElement, IToolTipItem{ public ToolTipProviderUIElement(UIElement parent) : base(parent) { this.ToolTipItem = this; }
protected override void DrawBackColor(ref UIElementDrawParams drawParams){}
protected override bool WantsInputNotification(UIElementInputType inputType, Point point) { return inputType == UIElementInputType.MouseHover; }
ToolTipInfo IToolTipItem.GetToolTipInfo(Point mousePosition, UIElement element, UIElement previousToolTipElement, ToolTipInfo toolTipInfoDefault) { toolTipInfoDefault.AutoPopDelay = 2000; toolTipInfoDefault.ToolTipText = "it worked"; return toolTipInfoDefault; }}
A slight variation to suggested code. Instead of creating new ToolTipUIElement you can set the ToolTipItem property on the ButtonUIElement
buttonElement.ToolTipItem = new ToolTipItem("title", "text");
private class ToolTipItem : IToolTipItem { readonly string m_toolTipTitle ; readonly string m_toolTipText ; public ToolTipItem(string toolTipTitle, string toolTipText) { m_toolTipTitle = toolTipTitle; m_toolTipText = toolTipText; } ToolTipInfo IToolTipItem.GetToolTipInfo(Point mousePosition, UIElement element, UIElement previousToolTipElement, ToolTipInfo toolTipInfoDefault) { toolTipInfoDefault.AutoPopDelay = 2000; toolTipInfoDefault.ToolTipText = m_toolTipText; toolTipInfoDefault.Title = m_toolTipTitle; return toolTipInfoDefault; } }
Hello everyone,
I have added ToolTips to my UltraComboEditor's ButtonsRight collection (containing 4 EditorButtons with individual tool tip texts) the way that Brian described above.
Unfortunately, AutoPopDelay doesn't do for me, since I do have other controls in my app that are using an UltraToolTipManager. That way it is possible that multiple tool tips are being shown at the same time.
I would need to determine when the mouse has left the EditorButton's Rect area and hide or reset the currently shown ToolTip respectively, but I can't get it to work.
Code from my UserControl:
private void cmeProfiles_MouseLeaveElement(object sender, UIElementEventArgs e) { EditorButtonCreationFilter creationFilter = cmeProfiles.CreationFilter as EditorButtonCreationFilter; creationFilter.DisableCurrentEditorButtonToolTip( cmeProfiles.UIElement.LastElementEntered); }
Code from my EditorButtonCreationFilter class:
public void DisableCurrentEditorButtonToolTip(UIElement lastElementEntered) { ButtonUIElementBase buttonElement = lastElementEntered as ButtonUIElementBase; if (buttonElement != null && buttonElement.HasChildElements) { for (int i = 0; i < buttonElement.ChildElements.Count; i++) { ToolTipProviderUIElement toolTipElement = buttonElement.ChildElements[i] as ToolTipProviderUIElement; if (toolTipElement != null) toolTipElement.ToolTipItem = null; } }}
I am pretty new to all this Infragistics stuff, sorry if I couldn't see the obvious. Brian already wrote that he could not figure out how to make the tool tip disappear after leaving the button, but maybe somebody can come up with an idea...
Alternatively, I would probably have to find a way how to use my UserControl's UltraToolTipManager for both normal controls and the UltraComboEditor's EditorButtons.
Thanks for your prompt reply Brian. I implemented the CreationFilter and also submitted the feature request. I hope to see that in the future!
Thanks.