[PR #2989] Attach UiaRenderer and Fire Selection Changed Events #25185

Open
opened 2026-01-31 09:07:49 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/2989

State: closed
Merged: Yes


Summary of the Pull Request

I recommend looking at this PR by commit.

This PR makes use of the UiaRenderer by attaching it to the TerminalControl and setting up selectionChanged events for accessibility.

References

#2447

PR Checklist

  • Closes none
  • CLA signed.
  • Tests added/passed
  • Requires documentation to be updated

Detailed Description of the Pull Request / Additional comments

Commit 1: attaching the UiaRenderer

The uiaRenderer is treated very similarly to the dxRenderer. We have a unique_ptr ref to it in the TermControl. This gets populated when the TermControlAutomationPeer is created (thus enabling accessibility).

To prevent every TermControl from sending signals simultaneously, we specifically only enable whichever one is in an active pane.

The UiaRenderer needs to send encoded events to the automation provider (in this case, TermControlAutomationPeer). We needed our own automation events so that we can reuse this model for ConHost. This is the purpose of IUiaEventDispatcher.

We need a dispatcher for the UiaRenderer. Otherwise, we would do a lot of work to find out when to fire an event, but we wouldn't have a way of doing that.

Commit 2: hooking up selection events

This provides a little bit of polish to hooking it up before. Primarily to actually make it work. This includes returning S_FALSE instead of E_NOTIMPL.

The main thing here really is just how to detect if a selection has changed. This also shows how clean adding more events will be in the future!

Validation Steps Performed

  1. Launch Windows Terminal
  2. Launch Narrator (WIN+CTRL+Enter)

Scenario 1: cell selection

click on a cell with text in it
Narrator should read it out

Scenario 2a: expand selection

Click on a cell with text in it and drag it over more text (extending the selection)
Narrator shouild read the first cell, then read either...

  • the entire selection
  • what was appended to the selection
    (this is still unclear to me when it does which one)

Scenario 2b: reduce selection

Make a selection of an entire word (i.e.: "Powershell")
Reduce the selection to the first character
Narrator should read what got unselected

Scenario 3: Double click

double click on a word
Narrator should read the entire selection

Scenario 4: Triple click

Triple click on a line
Narrator should read the entire selection

**Original Pull Request:** https://github.com/microsoft/terminal/pull/2989 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request I recommend looking at this PR by commit. This PR makes use of the UiaRenderer by attaching it to the TerminalControl and setting up selectionChanged events for accessibility. ## References #2447 ## PR Checklist * [x] Closes none * [x] CLA signed. * [x] ~Tests added/passed~ * [x] ~Requires documentation to be updated~ ## Detailed Description of the Pull Request / Additional comments ### Commit 1: attaching the UiaRenderer The `uiaRenderer` is treated very similarly to the `dxRenderer`. We have a unique_ptr ref to it in the `TermControl`. This gets populated when the `TermControlAutomationPeer` is created (thus enabling accessibility). To prevent every TermControl from sending signals simultaneously, we specifically only enable whichever one is in an active pane. The `UiaRenderer` needs to send encoded events to the automation provider (in this case, `TermControlAutomationPeer`). We needed our own automation events so that we can reuse this model for ConHost. This is the purpose of `IUiaEventDispatcher`. We need a dispatcher for the `UiaRenderer`. Otherwise, we would do a lot of work to find out when to fire an event, but we wouldn't have a way of doing that. ### Commit 2: hooking up selection events This provides a little bit of polish to hooking it up before. Primarily to actually make it work. This includes returning `S_FALSE` instead of `E_NOTIMPL`. The main thing here really is just how to detect if a selection has changed. This also shows how clean adding more events will be in the future! ## Validation Steps Performed 1. Launch Windows Terminal 2. Launch Narrator (WIN+CTRL+Enter) ### Scenario 1: cell selection click on a cell with text in it Narrator should read it out ### Scenario 2a: expand selection Click on a cell with text in it and drag it over more text (extending the selection) Narrator shouild read the first cell, then read either... - the entire selection - what was appended to the selection (this is still unclear to me when it does which one) ### Scenario 2b: reduce selection Make a selection of an entire word (i.e.: "Powershell") Reduce the selection to the first character Narrator should read what got unselected ### Scenario 3: Double click double click on a word Narrator should read the entire selection ### Scenario 4: Triple click Triple click on a line Narrator should read the entire selection
claunia added the pull-request label 2026-01-31 09:07:49 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25185