AvalonEdit icon indicating copy to clipboard operation
AvalonEdit copied to clipboard

Accessibity (Narrator) support

Open NeomMob opened this issue 5 years ago • 6 comments

I would like to implement Narrator support in AvalonEdit but I have absolutly no idea where to start. Any pointer?

NeomMob avatar Jun 05 '19 06:06 NeomMob

One particular puzzling item is automation peer events for the completion list. Any hints/pointers will be very helpful

sloutsky avatar Nov 04 '20 15:11 sloutsky

@dgrunwald, @christophwille, @mkonicek, @siegfriedpammer, any plans/hints/pointers regarding Narrator/JAWS support (for the completion list)?

guregini avatar Jul 29 '21 22:07 guregini

I have no experience with JAWS or any other narrator. Would you be able to provide some resources on the topic and then we might be able to add better support to AvalonEdit. From what I can see in the source code, we already have some automation peer support for the text editor itself. Is the completion window the only missing element? I suspect the search panel might need adjustments as well.

Would you be able to gather a list of missing features and bugs? Thanks!

siegfriedpammer avatar Dec 20 '21 13:12 siegfriedpammer

We don't use SearchPanel of AvalonEdit - but yes, it may have similar issue.

We could work-around a requirement for IntelliSense support by changing next functions in TextRangeProvider.cs:

           public bool Compare(ITextRangeProvider range)
	{
		TextRangeProvider other = (TextRangeProvider)range;
		// KUSTO addition
		if (textArea.ActiveIntelliSenseAutomationPeer != null)
		{
			Log("{0}.Compare({1}) [ActiveIntelliSenseAutomationPeer != null]= false", ID, other.ID);
			return false;
		}
		
		bool result = doc == other.doc
			&& segment.Offset == other.segment.Offset
			&& segment.EndOffset == other.segment.EndOffset;
		Log("{0}.Compare({1}) = {2}", ID, other.ID, result);
		return result;
	}

           public string GetText(int maxLength)
	{
		Log("{0}.GetText({1})", ID, maxLength);
		// KUSTO addition
		if (textArea.ActiveIntelliSenseAutomationPeer != null)
		{
			var result = textArea.ActiveIntelliSenseAutomationPeer.GetName();
			Log("{0}.GetText({1}) --> {2}", ID, maxLength, result);
			return result;
		}
		if (maxLength < 0)
			return doc.GetText(segment);
		else
			return doc.GetText(segment.Offset, Math.Min(segment.Length, maxLength));
	}

... and by adding a property to TextArea.cs:

        #region Kusto: AutomationPeers for IntelliSense
	/// <summary>
	/// Gets or sets active IntelliSense selection item automation peer
	/// </summary>
	public System.Windows.Automation.Peers.AutomationPeer ActiveIntelliSenseAutomationPeer { get; set; }
	#endregion

Then - we set 'ActiveIntelliSenseAutomationPeer' - with the AutomationPeer of the IntelliSense SelectedItem (and unsetting it when the IntelliSense is hidden).

This works fine with JAWS and Narrator. LMK if you would like me to create a PR with these changes - or if you have other ideas how to resolve it.

sloutsky avatar Dec 26 '21 15:12 sloutsky

Thank you for posting this! Yes, I would be interested in reviewing and testing a PR from you @sloutsky. However, I might not be able to focus on this topic until end of January/mid February, fyi.

siegfriedpammer avatar Dec 26 '21 18:12 siegfriedpammer

Please see it here: https://github.com/icsharpcode/AvalonEdit/pull/332

sloutsky avatar Dec 27 '21 08:12 sloutsky