Changeset 2418 for trunk

Show
Ignore:
Timestamp:
10/08/08 02:34:35 (3 months ago)
Author:
bzr
Message:

virtual buffers:

  • Override the CursorManager?'s selection property (_set_selection method) to perform tasks required when the caret moves, rather than calling _caretMovedToField() from _caretMovementScriptHelper(). This simplifies the code to update the caret and allows any code that works with CursorManagers? to use virtual buffers properly without special treatment. Additionally, it means that more of the logic is in the base virtual buffer.
  • _set_selection() handles scrolling to the object using the new scrollIntoView() method on NVDAObjects.
  • _set_selection() sets the review position, not just the navigator object. This means that the review position will follow the virtual buffer cursor within objects.
  • A new method, _shouldSetFocusToObj(), is used by _set_selection() to determine whether the object should receive focus.
Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk

    • Property bzr:revision-info
      •  

        old new  
        1 timestamp: 2008-10-06 19:20:03.456000090 +1000 
         1timestamp: 2008-10-08 06:56:10.128000021 +1000 
        22committer: James Teh <jamie@jantrid.net> 
        33properties:  
    • Property bzr:revision-id:v3-list-QlpoOTFBWSZTWbrL2vUAAB1VgAAQABCAQDrrnqAgAFCgaaGRkxBoTIJ6mmaNRwhndFAoNhZjh_YY4a01fOg1ulgNNC2UrzPdXXEnDpX8XckU4UJC6y9r1A..
      •  

        old new  
        1961962213 jamie@jantrid.net-20081006050758-8oez6b1vk34njebl 
        1971972214 jamie@jantrid.net-20081006092003-vmgctsl79vtejen3 
         1982217 jamie@jantrid.net-20081007205610-6oo6sj77usytyqvj 
    • Property bzr:file-ids
      •  

        old new  
        1 source/NVDAObjects/IAccessible/__init__.py      683@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2FIAccessible%2F__init__.py 
        2 source/NVDAObjects/__init__.py  683@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FNVDAObjects%2F__init__.py 
         1source/virtualBuffers/__init__.py       1675@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FvirtualBuffers%2F__init__.py 
         2source/virtualBuffers/gecko_ia2.py      1694@dbe06fc7-9119-0410-a01d-9dbf589ecbba:trunk:source%2FvirtualBuffers%2Fgecko_ia2.py 
  • trunk/source/virtualBuffers/__init__.py

    r2402 r2418  
    2525from gui import scriptUI 
    2626import virtualBufferHandler 
     27import eventHandler 
    2728 
    2829class VirtualBufferTextInfo(NVDAObjects.NVDAObjectTextInfo): 
     
    185186                pass 
    186187 
    187         def _caretMovedToField(self,dochandle,ID): 
    188                 pass 
     188        def _set_selection(self, info): 
     189                super(VirtualBuffer, self)._set_selection(info) 
     190                if isScriptWaiting() or not info.isCollapsed: 
     191                        return 
     192                api.setReviewPosition(info) 
     193                obj = info.NVDAObjectAtStart 
     194                if obj == self.rootNVDAObject: 
     195                        return 
     196                obj.scrollIntoView() 
     197                if not eventHandler.isPendingEvents("gainFocus") and obj != api.getFocusObject() and self._shouldSetFocusToObj(obj): 
     198                        obj.setFocus() 
     199 
     200        def _shouldSetFocusToObj(self, obj): 
     201                """Determine whether an object should receive focus. 
     202                Subclasses should override this method. 
     203                @param obj: The object in question. 
     204                @type obj: L{NVDAObjects.NVDAObject} 
     205                """ 
     206                return False 
    189207 
    190208        def script_activatePosition(self,keyPress): 
     
    199217                if self.VBufHandle is None: 
    200218                        return  
    201                 noKeyWaiting=not isScriptWaiting() 
    202                 if noKeyWaiting: 
    203                         oldDocHandle,oldID=VBufClient_getFieldIdentifierFromBufferOffset(self.VBufHandle,self.selection._startOffset) 
    204219                super(VirtualBuffer, self)._caretMovementScriptHelper(*args, **kwargs) 
    205                 if noKeyWaiting: 
    206                         docHandle,ID=VBufClient_getFieldIdentifierFromBufferOffset(self.VBufHandle,self.selection._startOffset) 
    207                         if ID!=0 and (docHandle!=oldDocHandle or ID!=oldID): 
    208                                 self._caretMovedToField(docHandle,ID) 
    209220 
    210221        def script_refreshBuffer(self,keyPress): 
     
    256267                                # We've expanded past the end of the field, so limit to the end of the field. 
    257268                                info.setEndPoint(fieldInfo, "endToEnd") 
    258                 info.updateCaret() 
    259269                speech.speakTextInfo(info, reason=speech.REASON_FOCUS) 
    260                 self._caretMovedToField(docHandle, ID) 
     270                info.collapse() 
     271                self.selection = info 
    261272 
    262273        @classmethod 
     
    305316                        else: 
    306317                                info=self.makeTextInfo(textHandler.Offsets(startOffset,endOffset)) 
    307                                 info.updateCaret() 
    308318                                speech.cancelSpeech() 
    309319                                speech.speakTextInfo(info,reason=speech.REASON_FOCUS) 
    310                                 self._caretMovedToField(docHandle,ID) 
     320                                info.collapse() 
     321                                self.selection = info 
    311322 
    312323                scriptUI.LinksListDialog(choices=[node[0] for node in nodes], default=defaultIndex if defaultIndex is not None else 0, callback=action).run() 
  • trunk/source/virtualBuffers/gecko_ia2.py

    r2381 r2418  
    143143                                        nextHandler() 
    144144                                newInfo.collapse() 
    145                                 newInfo.updateCaret() 
     145                                self.selection=newInfo 
    146146                else: 
    147147                        # The virtual buffer caret was already at the focused node, so we don't speak it. 
     
    155155                        obj.initAutoSelectDetection() 
    156156 
    157         def _caretMovedToField(self,docHandle,ID): 
    158                 try: 
    159                         pacc,accChildID=IAccessibleHandler.accessibleObjectFromEvent(docHandle,IAccessibleHandler.OBJID_CLIENT,ID) 
    160                         if not (pacc==self.rootNVDAObject.IAccessibleObject and accChildID==self.rootNVDAObject.IAccessibleChildID): 
    161                                 obj=NVDAObjects.IAccessible.IAccessible(IAccessibleObject=pacc,IAccessibleChildID=accChildID) 
    162                                 api.setNavigatorObject(obj) 
    163                                 obj.IAccessibleObject.scrollTo(GECKO_SCROLL_TYPE_ANYWHERE) 
    164                                 if not eventHandler.isPendingEvents('gainFocus') and controlTypes.STATE_FOCUSABLE in obj.states and obj.role!=controlTypes.ROLE_EMBEDDEDOBJECT: 
    165                                         obj.setFocus() 
    166                 except: 
    167                         pass 
     157        def _shouldSetFocusToObj(self, obj): 
     158                return controlTypes.STATE_FOCUSABLE in obj.states and obj.role!=controlTypes.ROLE_EMBEDDEDOBJECT 
    168159 
    169160        def _activateField(self,docHandle,ID): 
     
    277268                                speech.speakTextInfo(newInfo,reason=speech.REASON_FOCUS) 
    278269                                newInfo.collapse() 
    279                                 newInfo.updateCaret() 
     270                                self.selection=newInfo 
    280271 
    281272        def _tabOverride(self, direction): 
     
    331322                speech.speakTextInfo(newInfo,reason=speech.REASON_FOCUS) 
    332323                newInfo.collapse() 
    333                 newInfo.updateCaret() 
    334                 self._caretMovedToField(newDocHandle, newID) 
     324                self.selection=newInfo 
    335325                return True 
    336326