Skip to content

Commit

Permalink
Incubates #7489
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelDCurran committed Dec 11, 2017
2 parents a2a83c5 + 2e29741 commit d116e5c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
8 changes: 4 additions & 4 deletions source/braille.py
Expand Up @@ -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)))

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
32 changes: 22 additions & 10 deletions source/globalCommands.py
Expand Up @@ -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])
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d116e5c

Please sign in to comment.