Extending selection

General TRichView support forum. Please post your questions here
Post Reply
tuukka
Posts: 2
Joined: Wed Aug 27, 2008 10:16 am

Extending selection

Post by tuukka »

Assume that the editor has text/figures consisting of start_item, middle_item1, middle_item2, ..., middle_itemN, end_item. What I need is that whenever any part of any of those item is selected, all of them are selected. (Ideally, I would prefer treating all those items as a single block, but it does not seem to be possible since they are of different styles and they may be separated by line breaks.)

I can do that by calling SetSelectionBounds in OnSelect but that creates another OnSelect event. I can, of course, avoid infinite loop by recognizing the second time that Selection Bounds are already as desired, but it sounds like a kludge.
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I can, of course, avoid infinite loop by recognizing the second time that Selection Bounds are already as desired, but it sounds like a kludge.
As for me, it is a normal solution. If selection is not what you need, you change it, OnSelect occurs, but the selection becomes normal, and you do not modify it.
You can also consider using label items instead of text items (they can be selected only as a whole, but they do not support line wrapping).
Or consider using rvprStyleSplitProtect Protection option.
Post Reply