SmartTags Mouse Sensitive Area

SyntaxEditor for Windows Forms Forum

Posted 15 years ago by Joachim Schwieren
Avatar
Hi,

in the default configuration, a small red box is shown on the last character of a TextRange to which a SmartTag has been added to.

In newer versions of MS Office the full range of a smart tag text is decorated with a curly violet line. I managed to get this behaviour by using a custom span indicator for the smart tag but how can I enlarge the mouse sensitve zone that makes the popup menu appear?

E.g. if I have

This is a smart tag in a text.

And "smart tag" is the range where a SmartTag object is added to I want to see the popup as soon as the cursor hovers on any of the characters in "smart tag", not only on the "g" as it is now.

How can this be done?

Regards,

Joe

Comments (1)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Joe,

Our view's OnMouseHover handler has code like this:
// See if the mouse is over a smart tag
SmartTag smartTag = syntaxEditor.IntelliPrompt.SmartTag.ActiveSmartTag;
if ((eventArgs.HitTestResult.Offset != -1) && (eventArgs.HitTestResult.DocumentLine != null)) {
    DocumentLineSpanIndicatorCollection indicators = eventArgs.HitTestResult.DocumentLine.SpanIndicators;
    foreach (SpanIndicator indicator in indicators) {
        if ((indicator is SmartTagSpanIndicator) && (eventArgs.HitTestResult.Offset == indicator.TextRange.EndOffset - 1)) {
            smartTag = ((SmartTagSpanIndicator)indicator).SmartTag;
            if (smartTag != null)
                syntaxEditor.IntelliPrompt.SmartTag.Show(eventArgs.HitTestResult.Offset, smartTag);
        }
    }
}
You could probably do a similar thing but test for anything in the indicator's range before (.EndOffset - 1) so that it doesn't conflict with our code.


Actipro Software Support

The latest build of this product (v24.1.1) was released 24 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.