diff --git a/source/braille.py b/source/braille.py index e56847c999e..697306997d5 100644 --- a/source/braille.py +++ b/source/braille.py @@ -1709,7 +1709,7 @@ def handleGainFocus(self, obj, shouldAutoTether=True): return if shouldAutoTether: self.setTether(self.TETHER_FOCUS, auto=True) - elif self._tether != self.TETHER_FOCUS: + if self._tether != self.TETHER_FOCUS: return self._doNewObject(itertools.chain(getFocusContextRegions(obj, oldFocusRegions=self.mainBuffer.regions), getFocusRegions(obj))) @@ -1744,7 +1744,7 @@ def handleCaretMove(self, obj, shouldAutoTether=True): prevTether = self._tether if shouldAutoTether: self.setTether(self.TETHER_FOCUS, auto=True) - elif prevTether != self.TETHER_FOCUS: + if self._tether != self.TETHER_FOCUS: return region = self.mainBuffer.regions[-1] if self.mainBuffer.regions else None if region and region.obj==obj: @@ -1830,11 +1830,11 @@ def handleUpdate(self, obj): def handleReviewMove(self, shouldAutoTether=True): if not self.enabled: return - if not shouldAutoTether and self._tether != self.TETHER_REVIEW: - return reviewPos = api.getReviewPosition() if shouldAutoTether: self.setTether(self.TETHER_REVIEW, auto=True) + if self._tether != self.TETHER_REVIEW: + return region = self.mainBuffer.regions[-1] if self.mainBuffer.regions else None if region and region.obj == reviewPos.obj: self._doCursorMove(region) diff --git a/source/globalCommands.py b/source/globalCommands.py index 54aec95f533..1fc445dedea 100755 --- a/source/globalCommands.py +++ b/source/globalCommands.py @@ -1716,7 +1716,11 @@ def script_braille_toggleTether(self, gesture): if newTetherChoice==braille.handler.TETHER_REVIEW: braille.handler.handleReviewMove(shouldAutoTether=False) else: - braille.handler.handleGainFocus(api.getFocusObject(),shouldAutoTether=False) + focus = api.getFocusObject() + if focus.treeInterceptor and not focus.treeInterceptor.passThrough: + braille.handler.handleGainFocus(focus.treeInterceptor,shouldAutoTether=False) + else: + braille.handler.handleGainFocus(focus,shouldAutoTether=False) # Translators: Reports which position braille is tethered to # (braille can be tethered automatically or to either focus or review position). ui.message(_("Braille tethered %s") % labels[newIndex]) @@ -1924,18 +1928,26 @@ def script_braille_dots(self, gesture): script_braille_dots.category=SCRCAT_BRAILLE def script_braille_toFocus(self, gesture): + braille.handler.setTether(braille.handler.TETHER_FOCUS, auto=True) if braille.handler.getTether() == braille.handler.TETHER_REVIEW: self.script_navigatorObject_toFocus(gesture) else: - if not braille.handler.mainBuffer.regions: - return - region = braille.handler.mainBuffer.regions[-1] - braille.handler.mainBuffer.focus(region) - if region.brailleCursorPos is not None: - braille.handler.mainBuffer.scrollTo(region, region.brailleCursorPos) - elif region.brailleSelectionStart is not None: - braille.handler.mainBuffer.scrollTo(region, region.brailleSelectionStart) - braille.handler.mainBuffer.updateDisplay() + obj = api.getFocusObject() + region = braille.handler.mainBuffer.regions[-1] if braille.handler.mainBuffer.regions else None + if region and region.obj==obj: + braille.handler.mainBuffer.focus(region) + if region.brailleCursorPos is not None: + braille.handler.mainBuffer.scrollTo(region, region.brailleCursorPos) + elif region.brailleSelectionStart is not None: + braille.handler.mainBuffer.scrollTo(region, region.brailleSelectionStart) + braille.handler.mainBuffer.updateDisplay() + else: + # We just tethered to focus from review, + # Handle this case as we just focused the object + if obj.treeInterceptor and not obj.treeInterceptor.passThrough: + braille.handler.handleGainFocus(obj.treeInterceptor,shouldAutoTether=False) + else: + braille.handler.handleGainFocus(obj,shouldAutoTether=False) # Translators: Input help mode message for a braille command. script_braille_toFocus.__doc__= _("Moves the braille display to the current focus") script_braille_toFocus.category=SCRCAT_BRAILLE