Page 1 of 1

Lil' bug in SelectionExists method

Posted: Fri Mar 16, 2007 5:37 am
by Michael Pro
Actually, it's very implicit bug - but I've found it making my own editor and I want to tell how to fix it.
As you can see in sources SelectionExists method calls SelectionExists method with 2 flags, one of which is AllowReset. AllowReset had to be set false, if we're trying to select some part of the text, but if we use Richview method - it's true by default - and it's ok, if we use standard routines.
What I've done? Simply, I needed a method, which would track every change in the editor - and so I've set OnCaretMove event to make some kind of checks (it's related with setting statuses in another panel).
In one of this methods I'm calling RichViewEdit SelectionExists method and this affects the editor's work in a very funny way - it couldn't make selection with Shift+Arrow combination - only making move.
I've solved this problem in the easy way - by calling RvData.SelectionExists(false, true) not Self.SelectionExists method (method of RichViewEdit).

Posted: Fri Mar 16, 2007 7:43 am
by Sergey Tkachenko
I do not recommend working with selection in OnCaretMove, because selection may be incomplete when it is called.
Consider moving all code related to selection change in OnSelect, if possible.