SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

AvalonEdit -> Tooltips

Last post 05-30-2010 11:55 PM by DanielGrunwald. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-26-2009 9:46 AM

    AvalonEdit -> Tooltips

    What is the best way to show error description tooltips for syntax errors in AvalonEdit?

    I am highlighting the errors with custom DocumentColorizingTransformer. What I want to accomplish is to show the error description when user hovers the corresponding VisualLineElement.

    Thanks in advance.

    Filed under: ,
  • 02-26-2009 8:17 PM In reply to

    Re: AvalonEdit -> Tooltips

    The old ICSharpCode.TextEditor has a ToolTipRequested event; and I think I'll implement something similar in AvalonEdit.

    Until then, you'll have to implement it yourself - set timer in MouseMove, if timer elapses without further mouse movement, perform a hit test on the document (this is currently a bit messy - see TextView.GetVisualLineElementFromPosition) and show your tool tip.

  • 02-26-2009 11:08 PM In reply to

    Re: AvalonEdit -> Tooltips

    Thanks, that clears things up.
  • 05-30-2010 5:58 PM In reply to

    • AlexP
    • Not Ranked
    • Joined on 04-12-2010
    • Ireland
    • Posts 6

    Re: AvalonEdit -> Tooltips

    Hi Daniel,

    Did you have a chance to implement ToolTip support?

  • 05-30-2010 11:55 PM In reply to

    Re: AvalonEdit -> Tooltips

    There's no built-in tooltip support, but long ago I've added the TextEditor.MouseHover event which can be used to show tool tips.

    Example code:

            ToolTip toolTip = new ToolTip();
            
            void TextEditorMouseHover(object sender, MouseEventArgs e)
            {
                var pos = textEditor.GetPositionFromPoint(e.GetPosition(textEditor));
                if (pos !null) {
                    toolTip.PlacementTarget = this; // required for property inheritance
                    toolTip.Content = pos.ToString();
                    toolTip.IsOpen = true;
                    e.Handled = true;
                }
            }
            
            void TextEditorMouseHoverStopped(object sender, MouseEventArgs e)
            {
                toolTip.IsOpen = false;
            }

Page 1 of 1 (5 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.