eventHandler module
- eventHandler.lastQueuedFocusObject = None
the last object queued for a gainFocus event. Useful for code running outside NVDA’s core queue
- eventHandler.queueEvent(eventName, obj, **kwargs)
Queues an NVDA event to be executed. @param eventName: the name of the event type (e.g. ‘gainFocus’, ‘nameChange’) @type eventName: string
- eventHandler._queueEventCallback(eventName, obj, kwargs)
- eventHandler.isPendingEvents(eventName=None, obj=None)
Are there currently any events queued? @param eventName: an optional name of an event type. If given then only if there are events of this type queued will it return True. @type eventName: string @param obj: the NVDAObject the event is for @type obj: L{NVDAObjects.NVDAObject} @returns: True if there are events queued, False otherwise. @rtype: boolean
- class eventHandler._EventExecuter(eventName, obj, kwargs)
Bases:
TrackedObject
Facilitates execution of a chain of event functions. L{gen} generates the event functions and positional arguments. L{next} calls the next function in the chain.
- next()
- gen(eventName, obj)
- eventHandler._trackFocusObject(eventName: str, obj: NVDAObjects.NVDAObject) None
Keeps track of lastQueuedFocusObject and sets wasGainFocusObj attr on objects. :param eventName: the event type, eg “gainFocus” :param obj: the object to track if focused
- class eventHandler.FocusLossCancellableSpeechCommand(obj, reportDevInfo: bool)
Bases:
_CancellableSpeechCommand
@param reportDevInfo: If true, developer info is reported for repr implementation.
- _checkIfValid() bool
- _getDevInfo() str
- isLastFocusObj()
- previouslyHadFocus()
- isAncestorOfCurrentFocus()
- isForegroundObject()
- isMenuItemOfCurrentFocus() bool
Checks if the current object is a menu item of the current focus. The only known case where this returns True is the following (see #12624, #14550):
When opening a submenu in certain applications (like Thunderbird 78.12), NVDA can process a menu start event after the first item in the menu is focused. The menu start event causes a focus event on the menu, taking NVDA’s focus from the menu item. Additionally, the “menu” parent of the submenu item is not keyboard focusable, and is separate from the menu item which triggered the submenu. The object tree in this case (menu item > submenu (not keyboard focusable) > submenu item). The focus event order after activating the menu item’s sub menu is (submenu item, submenu).
- eventHandler._getFocusLossCancellableSpeechCommand(obj, reason: OutputReason) _CancellableSpeechCommand | None
- eventHandler.executeEvent(eventName: str, obj: NVDAObjects.NVDAObject, **kwargs) None
Executes an NVDA event. @param eventName: the name of the event type (e.g. ‘gainFocus’, ‘nameChange’) @param obj: the object the event is for @param kwargs: Additional event parameters as keyword arguments.
- eventHandler.handlePossibleDesktopNameChange() None
Reports the new virtual desktop name if changed. On Windows versions lower than Windows 10, this function does nothing.
- eventHandler.doPreGainFocus(obj: NVDAObjects.NVDAObject, sleepMode: bool = False) bool
- eventHandler.doPreDocumentLoadComplete(obj)
- eventHandler._acceptEvents = {}
set of (eventName, processId, windowClassName) of events to accept.
- eventHandler._acceptEventsByProcess = {}
Maps process IDs to sets of events so they can be cleaned up when the process exits.
- eventHandler.requestEvents(eventName=None, processId=None, windowClassName=None)
Request that particular events be accepted from a platform API. Normally, L{shouldAcceptEvent} rejects certain events, including most show events, events indicating changes in background processes, etc. This function allows plugins to override this for specific cases; e.g. to receive show events from a specific control or to receive certain events even when in the background. Note that NVDA may block some events at a lower level and doesn’t listen for some event types at all. In these cases, you will not be able to override this. This should generally be called when a plugin is instantiated. All arguments must be provided.
- eventHandler.handleAppTerminate(appModule)
- eventHandler.shouldAcceptEvent(eventName, windowHandle=None)
Check whether an event should be accepted from a platform API. Creating NVDAObjects and executing events can be expensive and might block the main thread noticeably if the object is slow to respond. Therefore, this should be used before NVDAObject creation to filter out any unnecessary events. A platform API handler may do its own filtering before this.