Skip to content

Try to use window.edit.Edit when an editable window supports it#8165

Merged
michaelDCurran merged 2 commits into
nvaccess:masterfrom
BabbageCom:editControls
May 8, 2018
Merged

Try to use window.edit.Edit when an editable window supports it#8165
michaelDCurran merged 2 commits into
nvaccess:masterfrom
BabbageCom:editControls

Conversation

@LeonarddeR

Copy link
Copy Markdown
Collaborator

Link to issue number:

Closes #8102
Closes #636

Summary of the issue:

NVDA uses the display model for editable text cases where there is a caret in the window and there doesn't seem to be another overlay class that implements editing. However, NVDA is a bit conservative in this, only using window.edit.Edit for objects with a particular window class or for windowless richEdit.

Description of how this pull request fixes the issue:

When finding an overlay class for an object and there is a caret in the window, rather than directly choosing DisplayModelEditableText, this pr will send the EM_LINELENGTH message to the window. This window message always returns 1 or higher for windows that support the edit API, also for single line edit controls. This means that, when the window responds with >=1 to EM_LINELENGTH, the edit API is supported. In this case, a new UnidentifiedEdit class is used that makes no assumptions about the edit API version. For these controls, this pr will try to construct an ITextDocumentTextInfo object to retrieve text information. If that fails, the implementation will fall back to EditTextInfo.

Testing performed:

Tested the notetab text editor. Instead of using DisplayModelEditableText for the edit control, UnidentifiedEdit is now used, and the control even implements ITextDocument support. Also tested a corporate Delphi application that has edit controls with custom window classes.

Known issues with pull request:

None

Change log entry:

…rts it regardless of window class. Also, try ITextDocument in more cases and remove old pre Windows Vista code

Inherrit from RichEdit

@michaelDCurran michaelDCurran 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.

This pr is rather hard to follow due to the large amount of constants moved to winUser. I understand why you did it, but there are various bits of code here which I'm confused as to why they are removed.

pDoc=None
if pDoc:
self._ITextDocumentObject=pDoc
self.useITextDocumentSupport=True

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.

Why was this removed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will explain this below.

start=end
end=watchdog.cancellableSendMessage(self.obj.windowHandle,EM_FINDWORDBREAK,WB_MOVEWORDRIGHT,offset)
return (start,end)
elif winVersion.winVersion.major<6: #Implementation of standard edit field wordbreak behaviour (only breaks on space)

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.

Why is all this code removed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Because it is code that would only apply to Windows XP.

editAPIVersion=0
editAPIUnicode=True
# #4291: Use ITextDocument in Windows 7 and later, as it's very slow in earlier versions.
useITextDocumentSupport=(winVersion.winVersion.major,winVersion.winVersion.minor)>=(6,1)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@michaelDCurran: the useITextDocumentSupport property seems to have been there to limit the support of ITextDocument to windows 7 and abbove. Since we aren't longer supporting Windows versions older than 7, this code now became obsolete (i.e. this variable would be always True). That's also the reason why I removed it from the IAccessible windowless rich text edit support as you saw.

@Qchristensen

Copy link
Copy Markdown
Member

One issue I've found from this PR, is moving the mouse while Notepad is open causes a lovely staccato of the error sound. The error it's generating is:

ERROR - eventHandler.executeEvent (13:00:27.961):
error executing event: mouseMove on <NVDAObjects.Dynamic_IAccessibleEditWindowNVDAObject object at 0x04F52B50> with extra args of {'y': 314, 'x': 953}
Traceback (most recent call last):
File "eventHandler.pyc", line 152, in executeEvent
File "eventHandler.pyc", line 92, in init
File "eventHandler.pyc", line 100, in next
File "NVDAObjects_init_.pyc", line 923, in event_mouseMove
File "documentBase.pyc", line 24, in makeTextInfo
File "textInfos\offsets.pyc", line 282, in init
File "NVDAObjects\window\edit.pyc", line 196, in _getOffsetFromPoint
NameError: global name 'EM_CHARFROMPOS' is not defined

LeonarddeR pushed a commit that referenced this pull request Apr 17, 2018
@LeonarddeR

Copy link
Copy Markdown
Collaborator Author

@Qchristensen commented on 17 Apr 2018, 05:25 CEST:

One issue I've found from this PR, is moving the mouse while Notepad is open causes a lovely staccato of the error sound.

Fixed in ebfe710 .

@Qchristensen

Copy link
Copy Markdown
Member

That's behaving better, thanks Leonard!

@beqabeqa473

Copy link
Copy Markdown
Contributor

hello.

maybe after this pull request i get this
ImportError: cannot import name EM_SETSEL

i wrote spell checker addon which gets and sets selection.
after some update i am getting this error and addon no longer works.
is it by design or it is a miss?

thanks.

@michaelDCurran

michaelDCurran commented May 3, 2018 via email

Copy link
Copy Markdown
Member

@LeonarddeR

LeonarddeR commented May 3, 2018

Copy link
Copy Markdown
Collaborator Author

@michaelDCurran commented on 3 mei 2018 09:04 CEST:

Those constants moved from NVDAObjects.window.edit to winUser.

I guess we could revert this change, but as Window.windowTextLineCount relies on one of these constants, the edit module didn't seem to be the right place for it. Add to that the fact that these constants live in winUser.h in the windows SDK.

@beqabeqa473

beqabeqa473 commented May 3, 2018 via email

Copy link
Copy Markdown
Contributor

@michaelDCurran michaelDCurran merged commit 874948c into nvaccess:master May 8, 2018
@nvaccessAuto nvaccessAuto added this to the 2018.2 milestone May 8, 2018
@LeonarddeR LeonarddeR added the BabbageWork Pull requests filed on behalf of Babbage B.V. label Oct 11, 2019
feerrenrut pushed a commit that referenced this pull request Sep 9, 2020
Fixes #8996

In #8165 we started using Unidentifiededit for editable text fields in which there is a caret and which seems to support Edit API. While both of these criterion's are true for Fast Log Entry edit fields their WindowText contains complete garbage and UnidentifiedEdit relies on Windowtext being correct.

Instead:
1. For edit field in Fast Log Entry DisplayModelEditableText is used similar to the pre #8165 
2. DisplayModelEditableText no longer inherits from EditableText rather from EditableTextWithoutAutoSelectDetection which makes selection announced when the color used for highlight in a particular app is the default Windows highlight color  - This has been suggested by @jcsteh in #4535
dawidpieper pushed a commit to dawidpieper/nvda that referenced this pull request Sep 13, 2020
…s#11488)

Fixes nvaccess#8996

In nvaccess#8165 we started using Unidentifiededit for editable text fields in which there is a caret and which seems to support Edit API. While both of these criterion's are true for Fast Log Entry edit fields their WindowText contains complete garbage and UnidentifiedEdit relies on Windowtext being correct.

Instead:
1. For edit field in Fast Log Entry DisplayModelEditableText is used similar to the pre nvaccess#8165 
2. DisplayModelEditableText no longer inherits from EditableText rather from EditableTextWithoutAutoSelectDetection which makes selection announced when the color used for highlight in a particular app is the default Windows highlight color  - This has been suggested by @jcsteh in nvaccess#4535
lukaszgo1 added a commit to lukaszgo1/nvda that referenced this pull request Dec 22, 2020
michaelDCurran added a commit that referenced this pull request Jan 11, 2021
* Don't use UnidentifiedEdit for windows with empty windowText

Fix-up of #8165

* Update what's new

Co-authored-by: Michael Curran <mick@nvaccess.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BabbageWork Pull requests filed on behalf of Babbage B.V.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use NVDAObjects.window.edit.Edit overlay class for editable windows with window text NVDA doesn't speak with NOTETAB text editor

5 participants