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; }}
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.
Hi,
weirdal said:Basically, I adapted the ToolTipContextHelperForGrid.cs to serve my needs with nested EditorButtons in an UltraTextEditor. Works like a charm :-)
Cool, that's what we wrote it for. :)
weirdal said:However, there is still some inconsistent behaviour: I have added an UltraListView as a drop down item to my UltraTextEditor. While the ListView is dropped down, ToolTips on the UltraTextEditor will not show. Also, while the UltraTextEditor is in EditMode, ToolTips will only be shown when the mouse pointer is over the border of the control, but not inside it (over the text area, that is).
When you drop down an EditorDropDownButton, you are displaying another form. Since that form now has the focus, your main form does not. ToolTipManager depends pretty heavily on the form it's on, so I suspect that's why this isn't working for you. The ToolTipManager is probably not showing the tooltip because the form is not active.
With the UltraTextEditor, it's a similar situation, but not quite the same. When this control goes into edit mode, it displays another control (a TextBox) on top of itself. So the UltraTextEditor will not be getting mouse messages when the mouse is over the contained control. There is a more detailed explanation of this here.
FAQ:Mouse events such as MouseDown, MouseUp, and DoubleClick do not fire for an UltraWinEditor it is in edit mode.
Thanks Mike, the sample you referenced has finally put me in the right direction. ToolTips work now with my existing ToolTipManager, so there are no conflicts any more with showing multiple tool tips at the same time.
Basically, I adapted the ToolTipContextHelperForGrid.cs to serve my needs with nested EditorButtons in an UltraTextEditor. Works like a charm :-)
However, there is still some inconsistent behaviour: I have added an UltraListView as a drop down item to my UltraTextEditor. While the ListView is dropped down, ToolTips on the UltraTextEditor will not show. Also, while the UltraTextEditor is in EditMode, ToolTips will only be shown when the mouse pointer is over the border of the control, but not inside it (over the text area, that is).
I have a temporary solution for this by simply checking on the AfterEnterEditMode event and immediately exiting EditMode if not over the drop down button. But I am wondering if there no more elegant solution to this behavior (like disabling edit mode, since there is no need for it in my app anyway)...
Anyway, thanks again for your support.
€: I originally attached my query to this already answered post, because it seemed to be about a similar topic. Is it always better to start a new thread instead?
I don't think there is any way for you to force the tooltip to close when you are applying it to the UIElements using a CreationFilter like you have here.
If you are already using an UltraToolTipManager elsewhere in your application, then you could use it for the editor buttons, too.
The down side of this approach is that, since all of the butttons are part of the same control, you will have to handle the showing of the tooltip yourself - you cannot just set the tooltip on the control and then change it as the mouse moves over the button, because once the tooltip is shown for the control, it wil not be shown again until the mouse leaves that control and comes back.
So what I would do is trap MouseEnterElement and watch for when the mouse enters one of the button UIElements. When it does, you apply the tooltip to the entire control and then start a timer. When the timer tick goes off, you show the tooltip.
Of course, if the mouse moves over another button, you will want to restart the timer. If the mouse moves outside of the control, you will want to stop the timer (if it's going).
It's a bit more work, but I think it should be doable.
You might also want to check out the ToolTips with Context sample. This is a sample project that demonstrates using UltraToolTipManager to show different tooltips for different parts of the same control. The sample uses a class which you can copy and use in your code and the modify it to look for the appropriate UIElements.
If you installed the samples with NetAdvantage, you can find the sample I am referring to under a path something like this:
...\2010.2\Samples\WinMisc\CS\ToolTipManager\ToolTips with Context CS