Skip to content

NVDAObjects.UIA: let NVDA recognize drag and drop states based on IsGrabbed property #14081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
josephsl opened this issue Aug 29, 2022 · 14 comments · Fixed by #14097
Closed

NVDAObjects.UIA: let NVDA recognize drag and drop states based on IsGrabbed property #14081

josephsl opened this issue Aug 29, 2022 · 14 comments · Fixed by #14097
Labels
api/uia Feature or bug requires an understanding of UIA p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Milestone

Comments

@josephsl
Copy link
Collaborator

Hi,

This issue stems from #12271

Is your feature request related to a problem? Please describe.

NVDA objects representing UIA elements can expose UIA patterns through dev info facility (NVDA+F1). While some patterns are mapped to object states, a number of useful patterns to states mapping are missing.

A prominent group of patterns relate to drag and drop. Specificaly, UIA elements can expose drag and drop target patterns for use by assistive technologies to inform users about draggable items. This is used in Narrator and NVDA (the latter via an add-on) to notify users about drag and drop target operations such as rearranging virtual desktops on Windows 11, placing Start menu times in Windows 10, and managing apps and folders in Windows 11 Version 22H2 Start menu. While these patterns are exposed by elements, they are not mapped to drag and drop target states yet.

Describe the solution you'd like

Since NVDA does come with drag and drop target states in control types package, let UIA NVDA objects add drag/drop target states based on exposed patterns.

Describe alternatives you've considered

None - cannot be done easily via add-ons as it touches NVDAObjects.UIA.UIA._get_states getter.

Additional context

This issue came from discussions surrouding #12271 as the pull request for it was unmanageable and led to user experience issues. Therefore, this issue serves as a starting point for resolving the mentioned issue in a series of pull requests to make the work more manageable.

Tanks.

@josephsl
Copy link
Collaborator Author

People who might be interested: @LeonarddeR, @codeofdusk, other UIA users. ONly after introducing drag/drop patterns to object states can a reimplementation of #12271 commence (I think it would make sense to not mess with gain focus events anymore as I have learned some things over the years that makes focus event queueing not worth it now).

@josephsl
Copy link
Collaborator Author

Hi,

Actualy, a simpler approach exists: UIA_IsGrabbedPropertyId (issue title changed).

Thanks.

@josephsl josephsl changed the title NVDAObjects.UIA: let NVDA recognize drag and drop target states based on UIA patterns NVDAObjects.UIA: let NVDA recognize drag and drop states based on IsGrabbed property Aug 30, 2022
@mzanm
Copy link
Contributor

mzanm commented Aug 31, 2022

I'm working on this and one issue I'm encountering is that IsGrabbed property only changes when dragging using the mouse, using the keyboard doesn't change it.

@josephsl
Copy link
Collaborator Author

josephsl commented Aug 31, 2022 via email

@mzanm
Copy link
Contributor

mzanm commented Aug 31, 2022

Yes, that's what I'm doing, it gets dragged and dropped but no grabbing property while holding alt + shift like how when the left button on the mouse is held down over an item.

@josephsl
Copy link
Collaborator Author

Hi,

Interesting. The way I resolved this in Windows Ap Essentials add-on (privately testing in canary channel a.k.a. source code level) is to map UIA drag start event to state change event, then in state change event inside the global plugin part of the add-on, check if is grabbed property is set and add "dragging" state to obj.states set. By the time UIA object gets to handle state change event (nextHandler function), NVDA will announce "dragging". But this is only one part of the puzzle: the other part, to be raised in a separate issue and will be addressed at the same time as this one, involves listening to UIA drag drop effect property changes and announcing the progress of drag drop process (same as Narrator). There is one last component which might be addressed in a separate PR: letting NVDA announce "done dragging" when drag and drop completes (this involves listening to UIA drag complete event). This whole algorithm responds to drag drop events set - there is another algorithm involved in listening to drop target events, which is not exacly the same thing as drag drop events set but somewhat related (that one will (finally) address NVDA not announcing placement progress when rearranging a variety of things, most notably Windows 10/11 quick actions). All these will be packaged as part of August 31st dev build of Windows App Essentials and may show up as part of 22.10 to stable channel subscribers in a few weeks.

So I propose that we compare our notes and see if we can come up with a common implementation (I think it would be better (in the long term) for me to step aside).

Thanks.

@josephsl
Copy link
Collaborator Author

Hi,

As for translating this into NVDA Core, this will involve editing at least two files: UIAHadler/init.py, and NVDAObjects/UIA/init.py. The former will add a few events and properties to UIA events/properties to NVDA events maps, and the latter will handle "is grabbed" property and map it to object states (NVDAObjects.UIA.UIA._get_states).

Thanks.

@mzanm
Copy link
Contributor

mzanm commented Aug 31, 2022

The way I tried to resolve this is I mapped the property directly to stateChanged
Is there a reason it wouldn't work that way?

@josephsl
Copy link
Collaborator Author

josephsl commented Aug 31, 2022 via email

@mzanm
Copy link
Contributor

mzanm commented Sep 1, 2022

Just tried that, state is announced with mouse, with keyboard it is grabbed but nothing.
I've also noticed that a pane that is the parent of the taskbar pinned icons is sending the drag start event, so it might be caused by that as it's not focused.

@josephsl
Copy link
Collaborator Author

josephsl commented Sep 1, 2022 via email

@seanbudd seanbudd added api/uia Feature or bug requires an understanding of UIA triaged Has been triaged, issue is waiting for implementation. p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority labels Sep 1, 2022
@mzanm
Copy link
Contributor

mzanm commented Sep 1, 2022

I've just tried latest windows app essentials addon from git and it has the same issue as my implementation.
Is it supposed to announce the dragging state when? I'm on windows 11 22 h 2 and I also tried on 21 h 2 before I upgraded and so far, I have tried rearranging taskbar icons, pinned tiles, virtual desktops, the dragging state does not get reported.
Edit: Does it only work on 10?

josephsl added a commit to josephsl/nvda that referenced this issue Sep 2, 2022
…s#14081.

When elements are about to be dragged, UIA sets 'IsGrabed' property to True. Add this property to UIA object states set so it can be detected and announced by NVDA (announcement is next commit).
josephsl added a commit to josephsl/nvda that referenced this issue Sep 2, 2022
… Re nvaccess#14081.

Treat 'is grabbed' property chnages as state changes. This will result in NVDA saying 'dragging' when items are grabbed, most notably when rearranging tiles in Windows 10 start menu.
@nvaccessAuto nvaccessAuto added this to the 2022.4 milestone Sep 2, 2022
seanbudd added a commit that referenced this issue Sep 2, 2022
Closes #14081

Summary of the issue:
NVDA does not recognize if a UIA element is about to be dragged when using keyboards.

Description of user facing changes
When a UIA element such as Windows 10 Start menu tile is about to be dragged and rearranged, NVDA will say "dragging" to indicate the dragging state.

Description of development approach
Add UIA "IsGrabbed" property to list of states to be handled by UIA objects, and map drag start UIA event to state change event.

* NVDAObjects.UIA: add support for UIA 'IsGrabbed' property. Re #14081.

When elements are about to be dragged, UIA sets 'IsGrabed' property to True. Add this property to UIA object states set so it can be detected and announced by NVDA (announcement is next commit).

* UIA handler: map UIA is grabbed property event to state change event. Re #14081.

Treat 'is grabbed' property chnages as state changes. This will result in NVDA saying 'dragging' when items are grabbed, most notably when rearranging tiles in Windows 10 start menu.

* update changes

Co-authored-by: Sean Budd <sean@nvaccess.org>
josephsl added a commit to josephsl/nvda that referenced this issue Sep 4, 2022
…nge events. Re nvaccess#14081.

Without defining UIA drag cancel and complete events, NVDA will not nanounce 'dragging' when dragging the selected item a second time (the added events do allow flushing staes cache as part of state change event, although NVDA will not nanounce 'done dragging' which is somethig to be investigated in the future).
@josephsl
Copy link
Collaborator Author

josephsl commented Sep 4, 2022

Hi,

Update: a follow-up pull request is on its way - adding and mapping UIA drag cancel and complete events to state changes.

seanbudd pushed a commit that referenced this issue Sep 5, 2022
…nge events. Re #14081. (#14104)

Additional fix for #14081
Follow-up to #14097

Summary of the issue:
NVDA is not announcing "dragging' when the item being dragged is let go and dragged again.

Description of user facing changes
When the item is grabbed a second tie, NVDA will announce 'dragging'.

Description of development approach
Add and map UIA drag cancel and complete events to state changes. This allows UIA object states cache to reflect the fact that "is grabbed" property is False, allowing NVDA to announce "dragging" when the item is grabbed again. At the moment NVDA will not say "done dragging" when drag complete event fires - that might be something to investigate in the future (remapping drag cancel/commplete events or doing soething with state change event/speech output).

Without defining UIA drag cancel and complete events, NVDA will not nanounce 'dragging' when dragging the selected item a second time (the added events do allow flushing staes cache as part of state change event, although NVDA will not nanounce 'done dragging' which is somethig to be investigated in the future).
@josephsl
Copy link
Collaborator Author

josephsl commented Oct 11, 2022 via email

seanbudd pushed a commit that referenced this issue Oct 23, 2022
…vent. Re #12271. (#14278)

Link to issue number:
Follow-up to #12271
Follow-up to #14081

Summary of the issue:
Follow-up/quick fix engineering for drag and drop effect announcement: suppose a user moves the mouse to an object that: is a UIA element, supports drag and drop, and is not a system focus. When drag and drop operation starts, drag drop effect is not announced, caused by the drag drop effect not being a global property event.

Description of user facing changes
Drag drop effect will be announced when performing drag and drop operation via mouse regardless of system focus, similar to drop target effect announcement.

Description of development approach
Add UIA_DragDropEffectPropertyId to global properties list to align with drop target effect property.

Follow-up/quick fix engineering for drag and drop effect announcement: suppose a user moves the mouse to an object that: is a UIA element, supports drag and drop, and is not a system focus. When drag and drop operation starts, drag drop effect is not announced, caused by the drag drop effect not being a global property event.
Beta branch justification: this is a bug fix/new feature introduced in NVDA 2022.4. Subsequent testing indicate that drag drop UIA property should have been a global property so the property can be announced based on mouse actions, simiar to reporting mouse when mouse tracking is turned on via mouse settings panel. This change also aligns with drop target effect announcement as drag and drop announcement issue covers both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api/uia Feature or bug requires an understanding of UIA p4 https://github.com/nvaccess/nvda/blob/master/projectDocs/issues/triage.md#priority triaged Has been triaged, issue is waiting for implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants