Changeset 2341

Show
Ignore:
Timestamp:
08/06/08 23:13:42 (4 months ago)
Author:
mdcurran
Message:

Gecko ia2 virtualBuffer: allow many links in gmail to actually be activated. Its a bad idea to try going up the ancestory until accDoDefaultAction works, it seems to do some very odd things with heavily scripted pages, and greatly stuffs up gmail. Also there was a major logic error in that particular code as if accDoDefaultAction failed, it would try doing a mouse click, but from inside the while loop... I'm not too sure whether break can be called from with in an except. Now if the object has no action, or accDoDefaultAction failes, we click. No more while loop.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/source/virtualBuffers/gecko_ia2.py

    r2340 r2341  
    173173                                virtualBufferHandler.reportPassThrough(self) 
    174174                        else: #Just try performing the default action of the object, or of one of its ancestors 
    175                                 while obj and obj!=self.rootNVDAObject: 
     175                                try: 
     176                                        action=obj.IAccessibleObject.accDefaultAction(obj.IAccessibleChildID) 
     177                                        if not action: 
     178                                                log.debugWarning("no default action for object") 
     179                                                raise RuntimeError("need an action") 
    176180                                        try: 
    177                                                 action=obj.IAccessibleObject.accDefaultAction(obj.IAccessibleChildID) 
    178                                                 if action: 
    179                                                         try: 
    180                                                                 obj.IAccessibleObject.accDoDefaultAction(obj.IAccessibleChildID) 
    181                                                         except: 
    182                                                                 l=obj.location 
    183                                                                 if l: 
    184                                                                         x=(l[0]+l[2]/2) 
    185                                                                         y=l[1]+(l[3]/2)  
    186                                                                         oldX,oldY=winUser.getCursorPos() 
    187                                                                         winUser.setCursorPos(x,y) 
    188                                                                         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None) 
    189                                                                         winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None) 
    190                                                                         winuser.setCursorPos(oldX,oldY) 
    191                                                         break 
     181                                                obj.IAccessibleObject.accDoDefaultAction(obj.IAccessibleChildID) 
    192182                                        except: 
    193                                                 pass 
    194                                         obj=obj.parent 
    195                 except: 
     183                                                log.debugWarning("error in calling accDoDefaultAction",exc_info=True) 
     184                                                raise RuntimeError("error in accDoDefaultAction") 
     185                                except: 
     186                                        log.debugWarning("could not programmatically activate field, trying mouse") 
     187                                        l=obj.location 
     188                                        if l: 
     189                                                x=(l[0]+l[2]/2) 
     190                                                y=l[1]+(l[3]/2)  
     191                                                oldX,oldY=winUser.getCursorPos() 
     192                                                winUser.setCursorPos(x,y) 
     193                                                winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN,0,0,None,None) 
     194                                                winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP,0,0,None,None) 
     195                                                winUser.setCursorPos(oldX,oldY) 
     196                                        else: 
     197                                                log.debugWarning("no location for field") 
     198                except: 
     199                        log.debugWarning("Error activating field",exc_info=True) 
    196200                        pass 
    197201