need help on text highlighting & capture backspace

SyntaxEditor for Windows Forms Forum

Posted 20 years ago by @hotmail.com
Avatar
Setting the BackColor property of a line can highlight the whole line. But if I just want to highlight some text from somewhere in the middle of line M to somewhere in the middle of line N programmatically, where N-M > 1. How can I do that?

I have tried to use ProcessDialogKey and KeyDown to capture Backspace key, but both of them couldn't catch the key. How can I do that?

Comments (5)

Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
To only highlight some text you'd have to create a SpanIndicator and assign that over the text range.

To get the Backspace key, right now you'll have to create a class that inherits from SyntaxEditor and overrides ProcessCmdKey. Right now the Backspace action is firing from the Backspace keypress and cancels the control from ever seeing it. We're going to be looking into revamping how keypresses work for a future version to try and make things like Backspace more accessible.


Actipro Software Support

Posted 20 years ago by @hotmail.com
Avatar
I can capture the Backspace key by using ProcessCmdKey method.

But I have on idea how to use SpanIndicator to select some text. Could you please provide some sample code to do that(such as how to initialize the SpanIndicator, how to put it in the indicator list, and how to set the select text range)?
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I think there is code in the sample app when there is a gutter click it puts a BreakpointIndicator over the selected text. Check that out.


Actipro Software Support

Posted 20 years ago by @hotmail.com
Avatar
How can I just select the text and don't draw the breakpoint if using the breakpointindicator?
Posted 20 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Just make a class that inherits from SpanIndicator and use that instead. When you call the base SpanIndicator constructor, pass IndicatorMarks.StyleAssignment. Then override the GetHighlightingStyle method. Here's the one for BreakoointIndicator as a sample:

/// <summary>
/// Returns the <see cref="HighlightingStyle"/> to use when drawing text within the indicator.
/// </summary>
/// <returns>The <see cref="HighlightingStyle"/> to use when drawing text within the indicator.</returns>
/// <remarks>This method should be implemented by indicators that have a style assignment.</remarks>
protected internal override HighlightingStyle GetHighlightingStyle() {
    return new HighlightingStyle("BreakpointStyle", "Breakpoint", foreColor, backColor, false, false, false);
}


Actipro Software Support

The latest build of this product (v24.1.0) 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.