Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions source/NVDAObjects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,10 @@ def event_gainFocus(self):
braille.handler.handleGainFocus(self)
brailleInput.handler.handleGainFocus(self)

def event_loseFocus(self):
# Forget the word currently being typed as focus is moving to a new control.
speech.clearTypedWordBuffer()

def event_foreground(self):
"""Called when the foreground window changes.
This method should only perform tasks specific to the foreground window changing.
Expand Down
2 changes: 2 additions & 0 deletions source/editableText.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ def _caretScriptPostMovedHelper(self, speakUnit, gesture, info=None):
braille.handler.handleCaretMove(self)

def _caretMovementScriptHelper(self, gesture, unit):
# Forget the word currently being typed as the user is moving the caret somewhere else.
speech.clearTypedWordBuffer()
try:
info=self.makeTextInfo(textInfos.POSITION_CARET)
except:
Expand Down
12 changes: 10 additions & 2 deletions source/speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ def speak(speechSequence, symbolLevel=None, priority=None):
for item in speechSequence:
if isinstance(item, basestring):
speechViewer.appendText(item)
global beenCanceled, curWordChars
curWordChars=[]
global beenCanceled
if speechMode==speechMode_off:
return
elif speechMode==speechMode_beeps:
Expand Down Expand Up @@ -2527,3 +2526,12 @@ def cancel(self):
#: The singleton _SpeechManager instance used for speech functions.
#: @type: L{_SpeechManager}
_manager = _SpeechManager()

def clearTypedWordBuffer():
"""
Forgets any word currently being built up with typed characters for speaking.
This should be called when the user's context changes such that they could no longer
complete the word (such as a focus change or choosing to move the caret).
"""
global curWordChars
curWordChars=[]