New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to automatically tether to focus or review #7489
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming it actually works (haven't tested this myself) I think it looks quite good. Just one or two small points.
source/NVDAObjects/__init__.py
Outdated
@@ -961,7 +961,7 @@ def event_foreground(self): | |||
def event_becomeNavigatorObject(self): | |||
"""Called when this object becomes the navigator object. | |||
""" | |||
braille.handler.handleReviewMove() | |||
braille.handler.handleReviewMove(shouldAutoTether=not eventHandler.lastReviewMoveDueToFollowing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable name isn't very clear if you don't have the surrounding context of this PR. Maybe choose another name?
source/api.py
Outdated
@@ -177,13 +177,14 @@ def getReviewPosition(): | |||
globalVars.reviewPosition,globalVars.reviewPositionObj=review.getPositionForCurrentMode(obj) | |||
return globalVars.reviewPosition | |||
|
|||
def setReviewPosition(reviewPosition,clearNavigatorObject=True): | |||
def setReviewPosition(reviewPosition,clearNavigatorObject=True, isCaret=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comma police. :) Also, the docstring needs updating.
source/api.py
Outdated
"""Sets a TextInfo instance as the review position. if clearNavigatorObject is true, It sets the current navigator object to None so that the next time the navigator object is asked for it fetches it from the review position. | ||
""" | ||
globalVars.reviewPosition=reviewPosition.copy() | ||
globalVars.reviewPositionObj=reviewPosition.obj | ||
if clearNavigatorObject: globalVars.navigatorObject=None | ||
braille.handler.handleReviewMove() | ||
eventHandler.lastReviewMoveDueToFollowing = isCaret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we be sure that this line and the one below it are only ever executed in one thread at a time?
source/braille.py
Outdated
@@ -28,6 +28,7 @@ | |||
from collections import namedtuple | |||
import re | |||
import scriptHandler | |||
import eventHandler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not too happy with another circular dependency, but I know we discussed this before and all solutions we came up with were hacky.
source/braille.py
Outdated
return | ||
reviewPos = api.getReviewPosition() | ||
#if reviewPos.obj == api.getFocusObject() and config.conf["reviewCursor"]["followFocus"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say just remove these two lines.
source/config/configSpec.py
Outdated
@@ -61,6 +61,7 @@ | |||
noMessageTimeout = boolean(default=false) | |||
messageTimeout = integer(default=4,min=0,max=20) | |||
tetherTo = string(default="focus") | |||
autoTether= boolean(default=false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space.
…ng event handlers, to support executing events with undefined kwargs.
… tethered to review before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel that auto tethering is really what we would want the majority NVDA user to be using, Therefore we should set autoTether to True by default.
But something is bothering me a little with this particular option as a checkbox. What happens if it is on, but tetherTo is set to review?
I assume autoTether in this case pretty much has no meaning?
source/eventHandler.py
Outdated
try: | ||
return func(*args, **self.kwargs) | ||
except TypeError: | ||
return extensionPoints.callWithSupportedKwargs(func, *args, **self.kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please log a clear message here (perhaps warning) so that we catch these issues pretty quick and fix them.
source/sayAllHandler.py
Outdated
@@ -151,7 +151,7 @@ def readTextHelper_generator(cursor): | |||
if cursor==CURSOR_CARET: | |||
updater.updateCaret() | |||
if cursor!=CURSOR_CARET or config.conf["reviewCursor"]["followCaret"]: | |||
api.setReviewPosition(updater) | |||
api.setReviewPosition(updater, isCaret=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should perhaps isCaret be only true if cursor==CURSOR_CARET?
source/appModules/lockapp.py
Outdated
|
||
def event_appModule_loseFocus(self): | ||
if not config.conf["reviewCursor"]["followFocus"]: | ||
api.setReviewPosition(self._oldReviewPos) | ||
api.setReviewPosition(self._oldReviewPos, isCaret=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As isCaret is False by default, explicitly specifying isCaret=False here is not needed, and is perhaps a little confusing. I'd prefer that anywhere in the codebase that isCaret is only ever specified if it needs to be set to true. Mirroring that of isFocus for setNavigatorObject.
It still has a meaning. When tethering is set to review and auto tethering is on, the initial tethering mode is review until auto tethering triggers focus. However, I agree that this is confusing. @dkager, @bramd, @jcsteh: thoughts? I'd suggest having three options, focus, review and auto. I recall from one of our braille discussions that @jcsteh preferred separate options for tethering mode focus/review and auto tethering on/off, because it allows you to quickly override the decision made by auto tethering. I belief that's the reason I implemented it as it is now. However, after thought about it a little more, I think i agree with Mick that it is a bit confusing from an UX perspective. |
As you have explained that autoTether works both ways, I'm now more
comfortable with the checkbox.
However, I would suggest that:
1. If the checkbox is checked, perhaps we could disable the combobox as
it has no meaning.
2. It would be nice to perhaps have the tether script toggle between
focus, review and auto... either that or have a separate script binding,
though I think this is a bit overkill.
|
Hi, I’m thinking a single script will be sufficient, similar to what we have for progress bar output and indentation tones. Thanks.
From: Michael Curran [mailto:notifications@github.com]
Sent: Thursday, November 23, 2017 2:00 PM
To: nvaccess/nvda <nvda@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: Re: [nvaccess/nvda] Add the ability to automatically tether to focus or review (#7489)
As you have explained that autoTether works both ways, I'm now more
comfortable with the checkbox.
However, I would suggest that:
1. If the checkbox is checked, perhaps we could disable the combobox as
it has no meaning.
2. It would be nice to perhaps have the tether script toggle between
focus, review and auto... either that or have a separate script binding,
though I think this is a bit overkill.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#7489 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgLkO_nXXARaKf3FBKeBtgZXXjJtH-Yks5s5erugaJpZM4O0rNh> .
|
Another way of handling this is to:
1. Have three options in the GUI (focus, review and auto).
2. When auto is enabled, the tether command should just temporarily
override the decision chosen by auto (which, based on your comments, is
what happens now).
I'm not sure it makes sense to have auto as an option for the command,
though. Auto never really stops being the case; the command just
temporarily overrides it until the next switch. So, if auto switched to
focus and you overrode it to review, it's still really in auto mode, so
having an auto option is misleading.
Perhaps we need to somehow indicate that the tether is temporary in auto
mode. "Braille temporarily tethered to review" would do this, but it's
ridiculously verbose.
|
I wonder if there really is much of a use case at all for temporarily
switching with the tether command while auto is enabled?
In the case of say reviewing a dos console window while typing, and
review follows caret is off, this becomes impossible because the caret
will still keep forcing tether to focus... I think.
|
Urg. You're right, but that's definitely a use case we need to think about,
since I'd say it's actually fairly common. If temporarily tethered to
review, I wonder if it makes sense to only tether to focus if the focus
moves, not the caret.
|
Having spoken to Jamie directly, we both agree that the GUI should just
be a combo box of auto, focus and review.
We discussed the config also reflecting this in that it is a key with
one of 3 values, though this would involve an upgrade step to force
previous configs from focus to auto. I think for this reason, and due to
the following number 2 point, it should remain as two separate config
keys as it is right now.
There are a few options for the tether command script:
1. Have it toggle between auto, focus and review. This is my personal
choice.
2. Leave it as is. I.e. toggles between focus and review When auto is
off, and temporarily between focus and review when auto is on, allowing
braille scrolling to control both review or caret, but it to snap back
when something else occurs.
In future we may want to think about something specific for review in
consoles, as these seem to be a special case where the user is forced to
use the review cursor because the caret is unable to move due to
scrolling etc.
Other peoples' thoughts?
|
@michaelDCurran commented on 24 nov. 2017 02:36 CET:
I agree.
This will probably be confusing for the end user. I'm intending to set the tetherTo config parameter to focus when the autoTether config parameter is True. We can also use the last state of tetherTo before enabling autoTether, but that will result into undefined behavior. |
Hmm, I haven't tested this yet, but making a toggle with three options seems the clearest interface to me as well. Some other thoughts: Given the use case that you want to read some text in a document or in a console and type at another location in the document or console, it's also needed to disable following of the caret by the review cursor. I know it is a lot of magic, but somehow having a toggle between auto/focus/review, it would make sense to turn review mode in a real review mode without being disturbed by caret/focus changes. |
This will need an update to the user guide for the tether setting. But looks good other than that. |
…n reviewing a terminal
…would result in the caret not being followed correctly. This also applies to the braille_toFocus script
I just pushed another commit that fixes #5237, tethering from review back to focus failed in browse mode. Also, the braille_toFocus script is now working much more reliably in auto tethering cases. @derekriemer reported issues with tethering on Gitter, but I can't reproduce them. Note that when using object review, it might look like you are tethered to focus even though you are tethered to review. You can check this by setting focus context representation to "always fill display" which gives you a more clear view of difference between focus and review tethering. @michaelDCurran: To be specific, there are now 3 new commits since your last review I belief. |
I have a strange behavior since this function is implemented. To reproduce it, the simplest is:
|
That's a very nice catch there. This, among other similar bugs, should have been fixed in the branch now, and will be visible as soon as review and incubation has taken place. |
…leReviewMove when tethered to focus
I am running on next-14726,ebbd6f4c. |
@Andre9642 commented on 12 dec. 2017 17:21 CET:
Could you please provide steps to reproduce? |
Sorry for the delayed response.
Unfortunately, it's complicated to reproduce and list all cases because sometimes I do not understand the steps that caused the problem...
I reproduced this on several machines, Word 2016 and NVDA version next-14726,ebbd6f4c. |
@Andre9642 commented on 14 dec. 2017 12:31 CET:
For me, the result always is as expected. Could you do the following at a python console: This parameter is reset to focus when explicitly thetering automatically, however when the tether setting has not been touched after an update and it was initially set to review, auto tethering is on and the config parameter is set to review, which should actually not be the case. |
I have another problem, I'm wondering if it's related: when I start/restart NVDA in a virtual document (eg: in Firefox, in a message in Thunderbird...), the browse mode is not enabled automatically. I am forced to leave and return to the virtual content. |
Could you test the latter with NVDA master? also, what dissplay are you using and which commands to scroll?
N.B. Sent on behalf of @BabbageCom
… Op 14 dec. 2017 om 17:23 heeft André-Abush Clause ***@***.***> het volgende geschreven:
>>> import config; print config.conf['braille']['tetherTo']
focus
I have another problem, I'm wondering if it's related: when I start/restart NVDA in a virtual document (eg: in Firefox, in a message in Thunderbird...), the browse mode is not enabled automatically. I am forced to leave and return to the virtual content.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@Andre9642: Also, just to make sure, do you have any configuration profiles active that might override the tethering setting? I've looked at the code again and, apart from what I mentioned in #7489 (comment) , I can't yet think of what might cause this behavior. The fact that I can't reproduce this makes it even more difficult to deal with it properly. |
@LeonarddeR I've just tested with the last master version. And... I have the same issue. I'm sorry, so this isn't related to this new feature! |
@Andre9642 commented on 14 dec. 2017 21:45 CET:
Just to make sure, which issue are you now referring to? The browse mode issue or the scrolling issue in Word? |
@LeonarddeR: Are you happy for this to be merged to master and closed? Also, can someone provide a what's new entry in the description? |
@Andre9642: Could you please answer my last question? Are the issues you were experiencing related to auto tethering or not? |
After all, no. I have the same problem with NVDA 2017.4 concerning the scrolling issue in Word. Regarding the browse mode issue, I have some instability (very) occasionally and randomly (= hard to reproduce). I don't know if it's related to auto tethering. :/ When this happens, the Braille display no longer follows if I move with arrow keys. I couldn't get this issue with NVDA 2017.4. |
@Andre9642 commented on 4 jan. 2018 01:55 CET:
Thanks for the clarification. May be you could answer the following questions?
|
@michaelDCurran commented on 2 jan. 2018 00:55 CET:
I just added a what's new entry. |
Link to issue number:
Fixes #2385
fixes #5237
Summary of the issue:
Currently, using the review cursor requires one to explicitly tether to review and back. See also #2385 (comment)
Description of how this pull request fixes the issue:
This adds the ability to the GUI to enable auto tethering. If set, NVDA will automatically tether to review for review cursor changes, and tethers back to focus when changing the focus or caret.
The following implementation is used, based on the proposal in #2385 (comment)
Ad a new boolean option to the config spec, autoTether
Replace the getter and setter for braille.BrailleHandler.tether with getTether and setTether methods. This is because setTether needs an additional keyword argument to determine whether it was an automatic or manual tether action. Of course, keep the old tether auto property for backwards compatibility, but deprecate it
Always show ui.reviewMessage in braille when auto tethering is on
Tether to review for several scripts in globalCommands, namely:
Add a new shouldAutoTether keyword argument to BrailleHandler.handleGainFocus, handleCaretMove and handleReviewMove. This argument should default to True, and can be set to False in places in the code base where this is explicitly required. Of course, shouldAutoTether should be ignored if the auto tethering option is disabled globally.
After some discussion with @dkager, we decided that using the several previous/next scripts to do auto tethering is ugly. Thus, to keep things in sync nicely, auto tethering is done by handleReviewMove instead. This has the following implications:
A. handleReviewMove should not auto tether when the move is caused due to the review cursor following the focus or the caret. Since most of the review following focus is done using api.setNavigatorObject with the isFocus parameter set to True, api.setNavigatorObject should somehow communicate this to handleReviewMove. However, setNavigatorObject doesn't execute handleReviewMove itself, but executes the becomeNavigatorObject event, which executes handleReviewMove. The isFocus parameter gets lost in this process. This is fixed by creating a caching variable, eventHandler.lastReviewMoveDueToFollowing. This new variable is also set properly by api.setReviewPosition based on a new parameter isCaret. At least for setNavigatorObject, I'd rather pass this info as an event parameter, but that means we break backwards compatibility.
B. There have been some edge cases that needed to be changed in setting the navigatorObject. For example, in the explorer appmodule on the SuggestionListItem class, the navigator object is set for event_UIA_elementSelected. This call of setNavigatorObject now has the extra isFocus parameter set to True.
Testing performed:
Various internal testing, but this needs to be tested more broadly. I'd like to request an initial review first, though.
Known issues with pull request:
None I'm currently aware of, except for the implications as noted above. And, no unit tests, as I really have no idea how to do this reliably.
Changelog entry