This is a migrated thread and some comments may be shown as answers.

Custom annotation that treats the entire annotation as a single item

2 Answers 133 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Frank
Top achievements
Rank 1
Frank asked on 11 Apr 2012, 08:10 PM
Hello,

I'm having trouble understanding the DeleteBehavior, BackspaceBehavior, and DeleteSelectedBehavior properties in annotations.  They do not seem to be working how I would expect them to.

I would like to have a custom annotation that works almost exactly like a read-only annotation range, but I would like to be able to select and delete the entire annotation range, including the text, from the UI.

I assumed that I would be able to customize this behavior by setting the DeleteBehavior, BackspaceBehavior, and DeleteSelectedBehavior, but it doesn't seem to work regardless of what settings I specify in those overridden properties.

Is it even possible to do what I am asking?

Thanks,

Frank

2 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 12 Apr 2012, 12:13 PM
Hi Frank,

We are still polishing the way the different behaviors work for the various annotation ranges types.

In a nutshell, you can achieve the desired behavior by inheriting from FieldRangeStartBase and FieldRangeEndBase and setting the SkipPositionsRange property of the range start to true, i.e.:

public override bool SkipPositionsInRange
{
    get
    {
        return true;
    }
}

Please find attached a demo illustrating the implementation. If you need further assistance, do not hesitate to contact us again.

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Frank
Top achievements
Rank 1
answered on 12 Apr 2012, 02:13 PM
Iva,

Your solution worked.  I was trying to do something similar on my own, but I think the key was in the way you instantiated the range markers.  I was just calling new SemanticRangeStart() and new SemanticRangeEnd(), but I believe creating them as a pair is what I needed to do and just did not realize.

Here is your code that I believe solved the problem:

SemanticRangeEnd rangeEnd = new SemanticRangeEnd();
SemanticRangeStart rangeStart = (SemanticRangeStart)rangeEnd.CreatePairedStart();

Thank you,

Frank
Tags
RichTextBox
Asked by
Frank
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Frank
Top achievements
Rank 1
Share this question
or