How do mark the current word

SyntaxEditor for WPF Forum

Posted 8 years ago by Frank Link - CEO, FLK Consulting UG
Version: 16.1.0633


how can i mark the current word with a underline when i pressed Alt-Key and Left Mouse Button and unmark them if i unpressed the keys?

I will mark the current word only.

Can you help me?



Comments (2)

Answer - Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Frank,

First you would need to handle the Alt key down plus left button down scenario.  You could do this if your syntax language has a IEditorViewMouseInputEventSink service.  Implement that interface in a custom class and register an instance of that class as a service on your syntax language.  Then in the NotifyMouseDown method, look for this particular scenario and mark e.Handled only when it occurs. 

You can get the word range with code like this:

var position = view.LocationToPosition(view.TransformToTextArea(e.GetPosition(view.VisualElement)), LocationToPositionAlgorithm.BestFit);
if (bestFitPosition != TextPosition.Empty) {
	var offset = this.PositionToOffset(position);
	var reader = view.CurrentSnapshot.GetReader(offset);
	// Find word range using reader here

 Next you need to make a custom classification tagger and register a tagger provider service for that on your syntax language.  Several of the adornments QuickStarts (like the AdornmentsIntraTextNotes one) show this sort of thing.  Classification tags can mark a range with a special tag.  In this case, you'd make a custom tag class for your use and mark the text range you determined above with that.  If your tagger is a CollectionTagger, then it's easy to add an instance of a tag range to that.  The QuickStart shows how.

That one QuickStart shows how in IntraTextNoteTag, a classification type registers a related highlighting style.  You'd need to do this where your highlighting style just sets the underline properties.

Once all that is in place, adding the custom classification tag to the tagger will underline the text range you determine.

Actipro Software Support

Posted 8 years ago by Frank Link - CEO, FLK Consulting UG


thanks for your help. It works very well.



The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.