Skip to content

NVDAObjects.UIA: announce drag and drop target effects#14101

Merged
seanbudd merged 15 commits into
nvaccess:masterfrom
josephsl:UIADragDropTargetEffects
Sep 6, 2022
Merged

NVDAObjects.UIA: announce drag and drop target effects#14101
seanbudd merged 15 commits into
nvaccess:masterfrom
josephsl:UIADragDropTargetEffects

Conversation

@josephsl

@josephsl josephsl commented Sep 2, 2022

Copy link
Copy Markdown
Contributor

Hi,

This is more of a second attempt at #12271

Link to issue number:

Fixes #12271
Follow-up and a different approach to #12428

Summary of the issue:

When drag and drop target events happen, NVDA does not announce their effects such as screen content changes such as effect of rearranging Start menu tiles.

Description of user facing changes

NVDA will announce effects of drag and drop events in places such as:

  • Windows 10 Start menu: after moving tiles
  • Windows 10 Action center/Windows 11 quick setings: afterreordering settings items
  • Windows 11 task view: rearranging virtual desktops
  • Windows 11 Start menu: rearranging pinned items, and from Version 22H2 onwards, creating app folders

Description of development approach

While this PR may look similar to #12428, the internals are different:

  • In UIA handler, added property events for drag drop and drop target effects.
  • In UIA objects, add property events for drag drop and drop target effects and announce effect text.
  • For drop target effect, because drop target event may come from somewhere other than the object that "raises" it, traverse focus ancestors looking for UIA elements with drop target effect text set.
  • Back in UIA handler, because drop target effect event can come from somewhere other than the focused element or its parent, treat it as a global event.

Testing strategy:

Manual and add-on based testing:

Testing drag drop effect (prerequisite: Windows 10):

  1. After building this PR from source, open Windows 10 Start menu.
  2. Press Shift+Tab to go to tiles.
  3. Press Alt+Shift+arrow keys to arrange tiles.
    Before the PR: NVDA says nothing about drag drop effect.
    After the PR: NVDA will announce the new position of the dragged tile.

Testing drop target effect (for best results, use Windows 11):

  1. After building the PR from source, open multiple virtual desktops (Control+Windows+D).
  2. Move to a virtual desktop (say, Desktop 1).
  3. Open task view (Windows+Ta), then move to desktops list.
  4. Press Alt+Shift+left/right arrows to reoder virtual desktops.

Before the PR: NVDA does not say anything about virtual desktop position.
After the PR: NVDA announces effect of reordering virtual desktop such as new item position.

Known issues with pull request:

This PR takes care of drag and drop target effect texts announcement, but does not include additional work for handling drag start/cancel/complete and drop target enter/leave/dropped events themselves (at least drag start event and the resulting dragging state change is handled by #14097). Should the need arise to handle actual drag and drop target events set, foundation is there to support them.

Change log entries:

Similar to #14097 but could be expanded to say (new features or bug fixes):

NVDA will announce effects of dragging items on screen in places such as rearranging Windows 10 Start menu tiles and virtual desktops in Windows 11. (#12271)

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

…ss#12271.

Revisiting NVDA issue 12271: UIA elements can provide drag drop effect, a text describing where the dragged object is located in relation to other elements. A somewhat related property, called drop target drop target effect property, is used by elements supporting drop target events to describe what happened when elements were dragged and dropped (rearranged in some cases). Most notably, the former property changes when rearranging Windows 10 Start menu tiles, and the latter property changes when rearranging virtual desktops in Windows 11.
As a first step, recognize drag drop effect property changes, with the actual implementation coming in the next commit.
.

Announce drag drop effect if it can be fetched (introduced in Windows 8).
…#12271.

The other side of drag and drop is drop target events set and their effects on the item being dragged and/or drop target element. For drop target effect, it is the element to which the dragged item can be dropped into, meaning it affects a different element other than the item being dragged at the moment. Therefore let NVDA anounce drop target effect property changes if given a chance to do so (implementation is the next commit).
…ess#12271.

Handle drop target effect property changes, hopefully from the object that actually is the target of a drag and drop operation. However there are cases where it is not the actual drop target element that records the effect property, notably when rearranging quick settings items in Windows 11. Therefore traverse focus ancestors until an element with drop target effect property is found and then report it as the effect property. The implication of this corner case is that drop target property change must be fetched globally (next commit).
…erty change event. Re nvaccess#12271.

Because drop target effect property can come from an element that is not necessarily the immediate focus element, treat it as though it is a global event. This is more so in Windows 11 Version 22H2 where selective UIA event registration is the default and drop target effect changes when rearranging quick settings items in Windows 11.
@josephsl josephsl requested a review from a team as a code owner September 2, 2022 04:49
@josephsl josephsl requested a review from seanbudd September 2, 2022 04:49
@josephsl

josephsl commented Sep 2, 2022

Copy link
Copy Markdown
Contributor Author

CC @Mazen428

@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 3792e90afe

…access#12271.

Because a drop target element can tell UIA that drop target effect can change many times, it becomes hard to notify users about latest happenings iwth drag and drop operation. Therefore cancel speech every time drop target effect property changes, similar to layout invalidated event where suggestions count changes multiple times.
…s. Re nvaccess#12271."

This reverts commit cd8f1d0 as it causes 'dragging' to not be announced when using the keyboard to rearrange tiles in Windows 10. It still causes effects to be announced continuously when using a mouse, so a different approach for dealing with input sources other than keyboards may need to be investigated.
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit 655a877d09

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could system tests be added using the manual testing example?

Comment thread source/UIAHandler/__init__.py Outdated
globalEventHandlerGroupUIAPropertyIds = {
UIA.UIA_RangeValueValuePropertyId
UIA.UIA_RangeValueValuePropertyId,
UIA.UIA_DropTargetDropTargetEffectPropertyId

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comma for easier diffs

Suggested change
UIA.UIA_DropTargetDropTargetEffectPropertyId
UIA.UIA_DropTargetDropTargetEffectPropertyId,

@josephsl

josephsl commented Sep 5, 2022 via email

Copy link
Copy Markdown
Contributor Author

@seanbudd

seanbudd commented Sep 5, 2022

Copy link
Copy Markdown
Member

@josephsl - yes I think the system test would need to only run on the known versions of Windows with the behaviour of the test.
I don't think it worth re-writing the test for different versions of Windows.
This might not be worth the long term upkeep if the behaviour varies a lot across Windows versions.

@josephsl

josephsl commented Sep 5, 2022 via email

Copy link
Copy Markdown
Contributor Author

@josephsl

josephsl commented Sep 5, 2022

Copy link
Copy Markdown
Contributor Author

Hi,

I think system tests cannot be done easily for this PR as drag and drop target effect text begins with a specific keyword ("place"). I'm sure it might be possible to detect substrings (text in str) but may need to read Robot framework docs more thoroughly. I think we might as well come up with an issue/PR pair (if it doesn't exist yet) just to deal with foundations to support Windows release detection (perhaps using sys.getwindowsversion function) and ways to detect substrings, as it can make future iterations of PR's like this easier to test locally in a more systematic way.

For anyone wishing to tackle system tests for PR's like this, you must first detect which Windows release the test system is running (perhaps using sys.getwindowsversion().platform_version), then emulate key presses (see existing system test robot files for details) and figure out what NVDA is saying or get a speech substring somehow.

Thanks.

@LeonarddeR LeonarddeR left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small thing

Comment thread source/NVDAObjects/UIA/__init__.py
Comment thread source/NVDAObjects/UIA/__init__.py Outdated
josephsl and others added 3 commits September 5, 2022 08:38
…is is not a UIA object


Suggested by Leonard de Ruijter: just continue the ancestor retrieval loop if NVDA came across a non-UIA object as it avoids handling COM error.

Co-authored-by: Leonard de Ruijter <leonardder@users.noreply.github.com>
Suggested by Leonard de Ruijter: now that only COM error is handled, there is no need to handle attribute error as cacheable value will not be fetched for non-UIA objects.

Co-authored-by: Leonard de Ruijter <leonardder@users.noreply.github.com>
@AppVeyorBot

Copy link
Copy Markdown

See test results for failed build of commit a66e8da9b2

@seanbudd seanbudd merged commit d10fd1a into nvaccess:master Sep 6, 2022
@nvaccessAuto nvaccessAuto added this to the 2022.4 milestone Sep 6, 2022
@josephsl josephsl deleted the UIADragDropTargetEffects branch October 8, 2022 20:07
@josephsl

josephsl commented Oct 11, 2022 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UIA handler: introduce UIA drag/drop event handlers for use with announcing items that were rearranged on screen

5 participants