-
-
Notifications
You must be signed in to change notification settings - Fork 626
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
added an @script decorator for setting script metadata to the scriptH… #6276
Conversation
source/baseObject.py
Outdated
continue | ||
scriptName = name[7:] | ||
if hasattr(script, 'gesture'): | ||
gestures[script.gesture] = scriptName |
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.
While I agree with having both gesture and gestures keyword arguments to the script decorator, I think the actual script functions should just have one "gestures" attribute. That is, the decorator should merge the two. Otherwise, everything that wants to look at a script's gestures has to check both attributes.
Otherwise, this looks good. Thanks! |
Now passing gesture to the ```@script``` decorator will append the gesture to the list of gestures, rather than setting both gesture and gestures attributes on the function.
Ug. As discussed on IRC, I realised this won't work with overlay classes. The reason is that we actually mutate the class after construction to insert overlay classes. That means that
|
@ctoth: I recall we discussed this pr some months ago but have forgotten the outcome of that discussion. Would you be able to address @jcsteh's comment? It might be good to have @jcsteh's comment also checked by a unit test, making sure that an object will also have the gestures added in an overlay. |
Since some further action is required, and there hasn't been any movement on this for a while, I would like to suggest that if anyone is interested they can take it on. This looks like a beneficial change to the NVDA code base. |
@feerrenrut: Happy to take this, but I have no rights to push to the original branch. @ctoth, would you be able to allow pushes from maintainers? If not, I"m afraid I'll just have to close this pr and open a new one. I agree that the code looks really useful. |
@LeonarddeR closing this one, merging from the |
@jcsteh: May I ask for your assistance, as I can't get it working very well.
Could you elaborate a bit more? Do you mean, instead of using cls._gestures, use cls.__gestures when adding the gestures from decorated scripts in the metaclass? I assume this will conflict when people would use both the script decorator and _-gestures on a class. Furthermore, it doesn't seem to work very well. The whole overlay class system is a bit hacky, and therefore I'm afraid we can't do anything else than what you suggested as per point 1:
|
Never mind, I have a working solution now that both respects self.__gestures and the gestures provided as part of a decorated script. I will first try to write proper unit tests before I'll file a new pr, this is really something that should be tested. |
…andler module
This necessitated a change to the base ScriptableObject class, as now it has to check its methods fore defined gestures.
I added getGestures and getScripts to the ScriptableObject public API, as they are used in the constructor and seemed useful, though I can make these methods private if it is demed preferable.
Fixes #6266