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!
Another option might be to use the MouseEnterElement and MouseLeaveElement events on the control to respectively show and hide a tooltip.
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.
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; }}