Skip to content

Commit 962dffd

Browse files
sloutskysiegfriedpammer
authored andcommitted
Add extension to text editor that allows to inject automation peer that represents IntelliSense suggesiton list and the currently selected suggestion - to allow screen narrators to read the suggestion.
1 parent 395ef81 commit 962dffd

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

ICSharpCode.AvalonEdit/Editing/TextArea.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,15 @@ public bool OverstrikeMode {
10851085

10861086
#endregion
10871087

1088+
#region AutomationPeer override for CodeCompletion
1089+
/// <summary>
1090+
/// Gets or sets AutomationPeer instance used by CodeCompletion.
1091+
/// CompletionWindow can use this property to inject AutomationPeer that reflects
1092+
/// the suggestion list and the value of the currently selected CompletionData item.
1093+
/// </summary>
1094+
public System.Windows.Automation.Peers.AutomationPeer CodeCompletionAutomationPeer { get; set; }
1095+
#endregion
1096+
10881097
/// <inheritdoc/>
10891098
protected override System.Windows.Automation.Peers.AutomationPeer OnCreateAutomationPeer()
10901099
{

ICSharpCode.AvalonEdit/Editing/TextRangeProvider.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public ITextRangeProvider Clone()
7676
public bool Compare(ITextRangeProvider range)
7777
{
7878
TextRangeProvider other = (TextRangeProvider)range;
79+
if (textArea.CodeCompletionAutomationPeer != null) {
80+
Log("{0}.Compare({1}) [ActiveIntelliSenseAutomationPeer != null]= false", ID, other.ID);
81+
return false;
82+
}
83+
7984
bool result = doc == other.doc
8085
&& segment.Offset == other.segment.Offset
8186
&& segment.EndOffset == other.segment.EndOffset;
@@ -194,6 +199,11 @@ public IRawElementProviderSimple GetEnclosingElement()
194199
public string GetText(int maxLength)
195200
{
196201
Log("{0}.GetText({1})", ID, maxLength);
202+
if (textArea.CodeCompletionAutomationPeer != null) {
203+
var result = textArea.CodeCompletionAutomationPeer.GetName();
204+
Log("{0}.GetText({1}) --> {2}", ID, maxLength, result);
205+
return result;
206+
}
197207
if (maxLength < 0)
198208
return doc.GetText(segment);
199209
else

0 commit comments

Comments
 (0)