Skip to content
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

Fix #9786 #9787

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions source/editableText.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class EditableText(TextContainerObject,ScriptableObject):

_hasCaretMoved_minWordTimeoutMs=30 #: The minimum amount of time that should elapse before checking if the word under the caret has changed

_caretMovementTimeoutMultiplier = 1
#: The caret movement timeout is multiplied by this value (useful for
#: controls where the caret is slow to move).
#: Set to a number grater than 0 to enable caret event handling
Copy link
Collaborator

Choose a reason for hiding this comment

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

grater > greater

#: (e.g. from UIA).
_caretMovementTimeoutMultiplier = 0

def _hasCaretMoved(self, bookmark, retryInterval=0.01, timeout=None, origWord=None):
"""
Expand All @@ -71,7 +75,8 @@ def _hasCaretMoved(self, bookmark, retryInterval=0.01, timeout=None, origWord=No
else:
# This function's arguments are in seconds, but we want ms.
timeoutMs = timeout * 1000
timeoutMs *= self._caretMovementTimeoutMultiplier
if self._caretMovementTimeoutMultiplier:
timeoutMs *= self._caretMovementTimeoutMultiplier
# time.sleep accepts seconds, so retryInterval is in seconds.
# Convert to integer ms to avoid floating point precision errors when adding to elapsed.
retryMs = int(retryInterval * 1000)
Expand All @@ -84,10 +89,11 @@ def _hasCaretMoved(self, bookmark, retryInterval=0.01, timeout=None, origWord=No
if eventHandler.isPendingEvents("gainFocus"):
log.debug("Focus event. Elapsed: %d ms" % elapsed)
return (True,None)
# Some controls implement a caret event
if eventHandler.isPendingEvents("caret"):
newInfo = self.makeTextInfo(textInfos.POSITION_CARET)
return (True, newInfo)
if self._caretMovementTimeoutMultiplier:
# Some controls implement a caret event
if eventHandler.isPendingEvents("caret"):
newInfo = self.makeTextInfo(textInfos.POSITION_CARET)
return (True, newInfo)
# If the focus changes after this point, fetching the caret may fail,
# but we still want to stay in this loop.
try:
Expand Down