In many cases my TreeNodes have additional text associated with them.I want to display this in a tooltip when the mouse is over the text part of the node only.
I have used MouseEnterElement() to [almost] determine whether I am over the text rather than the icon by checking the width of the UIElement.(if the width is 16 then it must be the icon)
However I have 2 problems.
1. There is a 1 pixel area above/below each icon that is not caught by this test. so if I move between icons the text briefly flashes. Is there a better way to determine that I am specifically over the Text element?
2. The automatic tooltips that you display when the text is not fully visible only display when the mouse is over the text - not the icon. Since I am displaying my own text in that situation I want to display the automatic text when the mouse is over the icon. (Either by changing a property to automatically display it when over the icon instead/in adition to over the text, or by detecting that the text is not fully displayed [while I am over the icon] and displaying the full text in my own tooltip.)
Thanks ... Mike
OK I got it to work that way.
However the isFullyVisible property of the NodeTextUIElement is ALWAYS True and the isTextFullyVisible property is ALWAYS False ... so these properties are useless.
I ended up comparing txtElem.Rect.Width = txtElem.TextSize.Width to determine if the text was fully visible.
Thanks
Hello Mike,
Thank you for your response.
You can get the NodeTextUIElement from the ImageUIElement by getting the ImageUIElement's Parent element and then calling GetDescendant() from the parent and passing in "typeof(NodeTextUIElement)" and casting the result to NodeTextUIElement.
For example: var textElement = e.Element.Parent.GetDescendant(typeof(NodeTextUIElement)) as NodeTextUIElement;
I had thought of that but how do I know whether the text is fully displayed?I only want to display a tool tip if the text is not fully visible, and I thought the only time I could get that information was in the MouseEnterElement event for the Text part of the node.
I believe your best option would be to add another if block to your handler for the MouseEnterElement event to check for an ImageUIElement and then programmatically display the node's text in a tooltip.
Please let me know if you have any other questions about this.
Thanks that works great for the first question.I had originally planned to use that method before switching to the size but I didn't know what type I was looking for.