1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Accessibility: Set caret position when passed an empty range selection in CodeEditorComponent and TextEditor AccessibilityTextInterface implementations

This commit is contained in:
ed 2021-06-08 17:56:43 +01:00
parent 005d45e0fe
commit a7f33da900
2 changed files with 14 additions and 1 deletions

View file

@ -2718,7 +2718,14 @@ private:
int getTotalNumCharacters() const override { return textEditor.getText().length(); }
Range<int> getSelection() const override { return textEditor.getHighlightedRegion(); }
void setSelection (Range<int> r) override { textEditor.setHighlightedRegion (r); }
void setSelection (Range<int> r) override
{
if (r.isEmpty())
textEditor.setCaretPosition (r.getStart());
else
textEditor.setHighlightedRegion (r);
}
String getText (Range<int> r) const override
{

View file

@ -71,6 +71,12 @@ private:
void setSelection (Range<int> r) override
{
if (r.isEmpty())
{
codeEditorComponent.caretPos.setPosition (r.getStart());
return;
}
auto& doc = codeEditorComponent.document;
codeEditorComponent.selectRegion (CodeDocument::Position (doc, r.getStart()),