I am currently implementing ITextRangeProvider and ITextRange interfaces to allow screen readers to gather information from a custom RichText control.
I am currently having a problem with the JAWS screen reader. When I navigate to the end or beginning of line using the right or left arrow keys JAWS will constantly call ITextRangeProvider.Move in an endless loop. This also blocks the ability to move the caret with the right and left arrow keys. My application appears frozen. This does not happen with the built-in Narrator screen reader.
When I navigate via the right and left arrow keys on a line of text (without reaching the beginning or end of line) the following trace output is generated (The result of right arrowing to the period character “.”:
int ITextRangeProvider.CompareEndpoints
void ITextRangeProvider.MoveEndpointByRange
void ITextRangeProvider.MoveEndpointByRange
void ITextRangeProvider.MoveEndpointByRange
int ITextRangeProvider.CompareEndpoints
int ITextRangeProvider.MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit=Character, int count=1)
string ITextRangeProvider.GetText(int maxLength=1)
string ITextRangeProvider.GetText selectedText.Length=1 selectedText="."
This output repeats 12 times in a row before it stops. Also, when I move the caret my caret location changed handler calls:
This.radRichTextBoxAutomationPeer.RaiseAutomationEvent(AutomationEvents.TextPatternOnTextSelectionChanged);
In my Visual Studio output window I see the following:
RaiseSelectionChanged='ScreenReaderIntegration.TextProvider.RaiseSelectionChanged()' is a 'method', which is not valid in the given context
The repeated trace output for each character and the "method not valid in given context" message are consistent for every character right or left arrow navigation except when I right arrow past the last character (in this case the “.”). When I right arrow past the period the lockup and blocked cursor movement happens, the following trace output is generated 7 times:
int ITextRangeProvider.CompareEndpoints
void ITextRangeProvider.MoveEndpointByRange
void ITextRangeProvider.MoveEndpointByRange
void ITextRangeProvider.MoveEndpointByRange
int ITextRangeProvider.CompareEndpoints
int ITextRangeProvider.MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit=Character, int count=1)
string ITextRangeProvider.GetText(int maxLength=1)
string ITextRangeProvider.GetText selectedText.Length=2 selectedText="\r\n"
Then the following trace output happens once:
void ITextRangeProvider.MoveEndpointByRange
void ITextRangeProvider.ExpandToEnclosingUnit(TextUnit unit=Format)
void ITextRangeProvider.MoveEndpointByRange
int ITextRangeProvider.CompareEndpoints
string ITextRangeProvider.GetText(int maxLength=-1)
string ITextRangeProvider.GetText selectedText.Length=0 selectedText=""
Then the following trace output happens in an endless loop while I can no longer move the caret:
ITextRangeProvider.Move unit=Format count=1
int ITextRangeProvider.MoveEndpointByUnit(TextPatternRangeEndpoint endpoint, TextUnit unit=Format, int count=1)
int ITextRangeProvider.CompareEndpoints
string ITextRangeProvider.GetText(int maxLength=-1)
string ITextRangeProvider.GetText selectedText.Length=0 selectedText=""
Is this a JAWS screen reader problem because Narrator does not show the same behavior?
Or, is this a problem with my interface implementation and are there any suggestions as to how to proceed to solve this problem?