Пример #1
0
def doPreGainFocus(obj, sleepMode=False):
    oldForeground = api.getForegroundObject()
    oldFocus = api.getFocusObject()
    oldTreeInterceptor = oldFocus.treeInterceptor if oldFocus else None
    api.setFocusObject(obj)
    if globalVars.focusDifferenceLevel <= 1:
        newForeground = api.getDesktopObject().objectInForeground()
        if not newForeground:
            log.debugWarning(
                "Can not get real foreground, resorting to focus ancestors")
            ancestors = api.getFocusAncestors()
            if len(ancestors) > 1:
                newForeground = ancestors[1]
            else:
                newForeground = obj
        api.setForegroundObject(newForeground)
        executeEvent('foreground', newForeground)
    if sleepMode: return True
    #Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
    for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
        executeEvent("focusEntered", parent)
    if obj.treeInterceptor is not oldTreeInterceptor:
        if hasattr(oldTreeInterceptor, "event_treeInterceptor_loseFocus"):
            oldTreeInterceptor.event_treeInterceptor_loseFocus()
        if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(
                obj.treeInterceptor, "event_treeInterceptor_gainFocus"):
            obj.treeInterceptor.event_treeInterceptor_gainFocus()
    return True
Пример #2
0
def doPreGainFocus(obj,sleepMode=False):
	oldForeground=api.getForegroundObject()
	oldFocus=api.getFocusObject()
	oldTreeInterceptor=oldFocus.treeInterceptor if oldFocus else None
	api.setFocusObject(obj)
	if globalVars.focusDifferenceLevel<=1:
		newForeground=api.getDesktopObject().objectInForeground()
		if not newForeground:
			log.debugWarning("Can not get real foreground, resorting to focus ancestors")
			ancestors=api.getFocusAncestors()
			if len(ancestors)>1:
				newForeground=ancestors[1]
			else:
				newForeground=obj
		api.setForegroundObject(newForeground)
		executeEvent('foreground',newForeground)
	if sleepMode: return True
	#Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
	for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
		executeEvent("focusEntered",parent)
	if obj.treeInterceptor is not oldTreeInterceptor:
		if hasattr(oldTreeInterceptor,"event_treeInterceptor_loseFocus"):
			oldTreeInterceptor.event_treeInterceptor_loseFocus()
		if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(obj.treeInterceptor,"event_treeInterceptor_gainFocus"):
			obj.treeInterceptor.event_treeInterceptor_gainFocus()
	return True
Пример #3
0
 def event_NVDAObject_init(self, obj):
     if obj.role == controlTypes.ROLE_DIALOG:
         api.setForegroundObject(obj)
         if obj.name == "New Document":
             obj.description = None
     #if api.getForegroundObject().name == "New Document":
     if obj.role in (controlTypes.ROLE_EDITABLETEXT,
                     controlTypes.ROLE_CHECKBOX):
         labelObj = obj.simplePrevious
         if labelObj and labelObj.role == controlTypes.ROLE_STATICTEXT:
             obj.name = labelObj.name
     if obj.role == controlTypes.ROLE_TABCONTROL:
         obj.windowControlID = 1
Пример #4
0
def doPreGainFocus(obj, sleepMode=False):
    oldForeground = api.getForegroundObject()
    oldFocus = api.getFocusObject()
    oldTreeInterceptor = oldFocus.treeInterceptor if oldFocus else None
    api.setFocusObject(obj)

    if speech.manager._shouldCancelExpiredFocusEvents():
        log._speechManagerDebug(
            "executeEvent: Removing cancelled speech commands.")
        # ask speechManager to check if any of it's queued utterances should be cancelled
        # Note: Removing cancelled speech commands should happen after all dependencies for the isValid check
        # have been updated:
        # - lastQueuedFocusObject
        # - obj.WAS_GAIN_FOCUS_OBJ_ATTR_NAME
        # - api.getFocusAncestors()
        # These are updated:
        # - lastQueuedFocusObject & obj.WAS_GAIN_FOCUS_OBJ_ATTR_NAME
        #   - Set in stack: _trackFocusObject, eventHandler.queueEvent
        #   - Which results in executeEvent being called, then doPreGainFocus
        # - api.getFocusAncestors() via api.setFocusObject() called in doPreGainFocus
        speech._manager.removeCancelledSpeechCommands()

    if globalVars.focusDifferenceLevel <= 1:
        newForeground = api.getDesktopObject().objectInForeground()
        if not newForeground:
            log.debugWarning(
                "Can not get real foreground, resorting to focus ancestors")
            ancestors = api.getFocusAncestors()
            if len(ancestors) > 1:
                newForeground = ancestors[1]
            else:
                newForeground = obj
        api.setForegroundObject(newForeground)
        executeEvent('foreground', newForeground)
    if sleepMode: return True
    #Fire focus entered events for all new ancestors of the focus if this is a gainFocus event
    for parent in globalVars.focusAncestors[globalVars.focusDifferenceLevel:]:
        executeEvent("focusEntered", parent)
    if obj.treeInterceptor is not oldTreeInterceptor:
        if hasattr(oldTreeInterceptor, "event_treeInterceptor_loseFocus"):
            oldTreeInterceptor.event_treeInterceptor_loseFocus()
        if obj.treeInterceptor and obj.treeInterceptor.isReady and hasattr(
                obj.treeInterceptor, "event_treeInterceptor_gainFocus"):
            obj.treeInterceptor.event_treeInterceptor_gainFocus()
    return True
Пример #5
0
 def event_focusEntered(self, obj, nextHandler):
     if obj.APIClass == UIA and obj.UIAElement.currentClassName == "BookInfo":
         api.setForegroundObject(obj)
         nextHandler()
     if obj.role != controlTypes.ROLE_SPLITBUTTON:
         nextHandler()
Пример #6
0
 def event_gainFocus(self):
     api.setForegroundObject(self)
     self.description = ""
     if not self.focusDialog():
         self.moveToItem(self.appModule.tpItemIndex)
Пример #7
0
 def event_gainFocus(self):
     self.reportFocus()
     api.setForegroundObject(self)
Пример #8
0
	def event_gainFocus(self):
		super(VLCBehaviorsDialog, self).event_gainFocus()
		# this dialog is necessary the foreground object
		api.setForegroundObject(self)