editableText module
Common support for editable text. @note: If you want editable text functionality for an NVDAObject,
you should use the EditableText classes in L{NVDAObjects.behaviors}.
- class editableText.EditableText(*args, **kwargs)
Bases:
TextContainerObject
,ScriptableObject
Provides scripts to report appropriately when moving the caret in editable text fields. This does not handle the selection change keys. To have selection changes reported, the object must notify of selection changes. If the object supports selection but does not notify of selection changes, L{EditableTextWithoutAutoSelectDetection} should be used instead.
- If the object notifies of selection changes, the following should be done:
When the object gains focus, L{initAutoSelectDetection} must be called.
When the object notifies of a possible selection change, L{detectPossibleSelectionChange} must be called.
Optionally, if the object notifies of changes to its content, L{hasContentChangedSinceLastSelection} should be set to C{True}.
@ivar hasContentChangedSinceLastSelection: Whether the content has changed since the last selection occurred. @type hasContentChangedSinceLastSelection: bool
- shouldFireCaretMovementFailedEvents = False
Whether to fire caretMovementFailed events when the caret doesn’t move in response to a caret movement key.
- announceNewLineText = True
Whether or not to announce text found before the caret on a new line (e.g. auto numbering)
- announceEntireNewLine = False
When announcing new line text: should the entire line be announced, or just text after the caret?
- _hasCaretMoved_minWordTimeoutSec = 0.03
The minimum amount of time that should elapse before checking if the word under the caret has changed
- _useEvents_maxTimeoutSec = 0.06
The maximum amount of time that may elapse before we no longer rely on caret events to detect movement.
- _caretMovementTimeoutMultiplier = 1
- _hasCaretMoved(bookmark, retryInterval=0.01, timeout=None, origWord=None)
Waits for the caret to move, for a timeout to elapse, or for a new focus event or script to be queued. @param bookmark: a bookmark representing the position of the caret before it was instructed to move @type bookmark: bookmark @param retryInterval: the interval of time in seconds this method should wait before checking the caret each time. @type retryInterval: float @param timeout: the over all amount of time in seconds the method should wait before giving up completely,
C{None} to use the value from the configuration.
@type timeout: float @param origWord: The word at the caret before the movement command,
C{None} if the word at the caret should not be used to detect movement. This is intended for use with the delete key.
@return: a tuple containing a boolean denoting whether this method timed out, and a TextInfo representing the old or updated caret position or None if interupted by a script or focus event. @rtype: tuple
- _caretScriptPostMovedHelper(speakUnit, gesture, info=None)
- _caretMovementScriptHelper(gesture, unit)
- _get_caretMovementDetectionUsesEvents() bool
Returns whether or not to rely on caret and textChange events when finding out whether the caret position has changed after pressing a caret movement gesture. Note that if L{_useEvents_maxTimeoutMs} is elapsed, relying on events is no longer reliable in most situations. Therefore, any event should occur before that timeout elapses.
- script_caret_newLine(gesture)
- _caretMoveBySentenceHelper(gesture, direction)
- script_caret_moveByLine(gesture)
- script_caret_moveByCharacter(gesture)
- script_caret_moveByWord(gesture)
- script_caret_moveByParagraph(gesture)
- script_caret_previousSentence(gesture)
- script_caret_nextSentence(gesture)
- _backspaceScriptHelper(unit, gesture)
- script_caret_backspaceCharacter(gesture)
- script_caret_backspaceWord(gesture)
- _deleteScriptHelper(unit, gesture)
- script_caret_deleteCharacter(gesture)
- script_caret_deleteWord(gesture)
- script_caret_previousParagraph(gesture: InputGesture) None
- script_caret_nextParagraph(gesture: InputGesture) None
- __gestures = {'kb:alt+downArrow': 'caret_nextSentence', 'kb:alt+upArrow': 'caret_previousSentence', 'kb:backspace': 'caret_backspaceCharacter', 'kb:control+backspace': 'caret_backspaceWord', 'kb:control+delete': 'caret_deleteWord', 'kb:control+downArrow': 'caret_nextParagraph', 'kb:control+end': 'caret_moveByLine', 'kb:control+home': 'caret_moveByLine', 'kb:control+leftArrow': 'caret_moveByWord', 'kb:control+numpadDelete': 'caret_deleteWord', 'kb:control+rightArrow': 'caret_moveByWord', 'kb:control+upArrow': 'caret_previousParagraph', 'kb:delete': 'caret_deleteCharacter', 'kb:downArrow': 'caret_moveByLine', 'kb:end': 'caret_moveByCharacter', 'kb:home': 'caret_moveByCharacter', 'kb:leftArrow': 'caret_moveByCharacter', 'kb:numpadDelete': 'caret_deleteCharacter', 'kb:pageDown': 'caret_moveByLine', 'kb:pageUp': 'caret_moveByLine', 'kb:rightArrow': 'caret_moveByCharacter', 'kb:shift+backspace': 'caret_backspaceCharacter', 'kb:shift+delete': 'caret_deleteCharacter', 'kb:shift+numpadDelete': 'caret_deleteCharacter', 'kb:upArrow': 'caret_moveByLine'}
- _autoSelectDetectionEnabled = False
- initAutoSelectDetection()
Initialise automatic detection of selection changes. This should be called when the object gains focus.
- detectPossibleSelectionChange()
Detects if the selection has been changed, and if so it speaks the change.
- _updateSelectionAnchor(oldInfo, newInfo)
- terminateAutoSelectDetection()
Terminate automatic detection of selection changes. This should be called when the object loses focus.
- _abc_impl = <_abc._abc_data object>
- caretMovementDetectionUsesEvents
- class editableText.EditableTextWithoutAutoSelectDetection(*args, **kwargs)
Bases:
EditableText
In addition to L{EditableText}, provides scripts to report appropriately when the selection changes. This should be used when an object does not notify of selection changes.
- reportSelectionChange(oldTextInfo)
- script_caret_changeSelection(gesture)
- __changeSelectionGestures = ('kb:shift+upArrow', 'kb:shift+downArrow', 'kb:shift+leftArrow', 'kb:shift+rightArrow', 'kb:shift+pageUp', 'kb:shift+pageDown', 'kb:shift+control+leftArrow', 'kb:shift+control+rightArrow', 'kb:shift+control+upArrow', 'kb:shift+control+downArrow', 'kb:shift+home', 'kb:shift+end', 'kb:shift+control+home', 'kb:shift+control+end', 'kb:control+a')
- initClass()
- _abc_impl = <_abc._abc_data object>