Re: Do I need to call SetSel?
Andrew Truckle <[email protected]> Mon, 20 Jan 2025 08:58:54 -0800 (PST)
| Newsgroups | gmane.comp.lib.scintilla.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Mitchell, I appreciate the explanation. And, I can confirm that using m_edit.SetEmptySelection(currentPos); works as expected. Thanks again. Andy On Monday, 20 January 2025 at 15:16:16 UTC Mitchell wrote: > Hi, > > > On Jan 20, 2025, at 5:28 AM, Andrew Truckle <[email protected]> wrote: > > > > I am using OnAutoCCompleted to detect that the user has selected <!-- > from the drop list. Then, I add the trailing --> and adjust the caret > position: > > > > if (strSelectedText == L"!--") { > > // Get the current caret position > > const auto currentPos = m_edit.GetCurrentPos(); > > > > // Insert the closing part --> > > m_edit.InsertText(currentPos, L"-->"); > > > > // Move the caret between <!-- and --> > > m_edit.SetCurrentPos(currentPos); > > m_edit.SetSel(currentPos, currentPos); // Clear selection to place caret > > } > > > > Is it obligatory that I need to call SetSel? > > Since you called `SetCurrentPos()`, which just sets the caret (not the > anchor), that will create a selection (intentional or not). The call to > `SetSel()` corrects this, so it is obligatory for your case. > > You could replace the two calls with a single call to > `SetEmptySelection(currentPos)` which ought to have the same effect. > > Cheers, > Mitchell -- You received this message because you are subscribed to the Google Groups "scintilla-interest" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/scintilla-interest/6d5df780-1b5b-4e87-a9be-658c7b82a5e4n%40googlegroups.com.