Read-only states for UIA objects#10494
Conversation
|
Thanks for this contribution. I think that the code will be more readable if the STATE_READONLY state is only added once in the code. Something like this: |
Thanks to @LeonarddeR for the suggestion.
| if isReadOnly != UIAHandler.handler.reservedNotSupportedValue: | ||
| states.add(controlTypes.STATE_READONLY) | ||
|
|
||
| if ( |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| document = self.UIATextPattern.documentRange | ||
| isReadOnly = document.GetAttributeValue(UIAHandler.UIA_IsReadOnlyAttributeId) | ||
| # We can check "isReadOnly" again | ||
| if isReadOnly: |
There was a problem hiding this comment.
I think reservedNotSupportedValue evaluates to True. I think we either need to do
| if isReadOnly: | |
| if isReadOnly and isReadOnly != UIAHandler.handler.reservedNotSupportedValue: |
or
| if isReadOnly: | |
| if isReadOnly is True: |
This is to ensure "isReadOnly" is not "reservedNotSupportedValue" when returning from document range. Additionally, this value is set if there is a "COMError".
This reverts commit 879e9b3.
Applied suggested change from @LeonarddeR.
There was a problem hiding this comment.
Thanks for this.
One additional suggestion in which case this new patch improves things.
In the outlook appModule, OutlookUIAWordDocument class, the isReadonlyViewer property can now simply return controlTypes.STATE_READONLY in self.states. SO, we no longer have to rely on the object model.
I leave it up to you whether you want to file this as a separate pr after this one, or do it in this one. I think it makes sense to do it as part of this pr.
Now it reports the read-only flag according to the state if it is added to the "states" set.
LeonarddeR
left a comment
There was a problem hiding this comment.
Thanks @francipvb, confirmed that Outlook still behaves as expected with this.
|
@michaelDCurran I think this code looks ok. Could either you or @feerrenrut have a look? This one is pretty small, so shouldn't take longer than a minute or five. |
feerrenrut
left a comment
There was a problem hiding this comment.
Overall this looks good, thank you @francipvb . Please let me know if you won't have time to extract the method.
| if self._getUIACacheablePropertyValue(UIAHandler.UIA_IsRequiredForFormPropertyId): | ||
| states.add(controlTypes.STATE_REQUIRED) | ||
|
|
||
| # Read-only state |
There was a problem hiding this comment.
Could you please extract this whole section into a new private method _getIsReadOnlyState()
|
Hello,
I don't have time to code on NVDA right now, too much work. I'm sorry...
…--
Cuando tus fuerzas terminan, las de mi Dios comienzan.
|
Link to issue number:
None.
Summary of the issue:
For various WPF text controls, read-only state isn't added. This is because the current implementation only tries to get the ValueIsReadOnly property. However WPF text controls don't support it.
Description of how this pull request fixes the issue:
This PR adds checks and looks at the document range from the text pattern, if the control implements it. Then it checks for the Is Read-Only attribute and adds the state according to the returned value.
Testing performed:
Tested with output text view of Visual Studio 2019.
Known issues with pull request:
None known.
Change log entry:
Section: Changes