Skip to content
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

Developer Guide: Clarify how to leave scripts unbound in ScriptableObject.__gestures #4039

Closed
nvaccessAuto opened this issue Mar 29, 2014 · 11 comments

Comments

@nvaccessAuto
Copy link

Reported by nvdakor on 2014-03-29 02:37
Hi,
With the addition of Input Gestures dialog in 2013.3, users can now assign, change and remove gestures (keyboard commands, braille display commands, etc.). This facility works as expected in most cases (and modules) except when a module has partial gesture assignments; that is, some scripts have gesture bindings, while others does not. This is mostly for some add-ons and future add-ons where an add-on writer may elect to leave some of the commands unassigned as they might conflict with core gestures.

Setup:

  1. Create a module (a global plugin will work).
  2. In the module, write a single script that does anything (I recommend writing a UI.message script), then write a doc method for it. Then:

A. Bind a command to this script. Restart NVDA and look at the Input Gestures dialog where you'll find the new script with your bindings.
B. Remove the script binding from the module code (to do this, use the key of None in the gestures dictionary instead of the gesture identifier). Restart NVDA, and go to Input Gestures dialog. You'll see your script with the gesture unassigned.

  1. Back in the module, write a second and/or a third script that does something different, then write a doc method for each. Then:

A. Assign gestures for your scripts, save the module, restart NVDA and open Input Gestures dialog. Your new scripts and the commands for them are listed.
B. Remove a gesture from your script(s) with Input Gestures, then select OK. Next time you open Input Gestures, you'll see that the gestures for your other scripts are unaffected.
C. Back at Input Gestures dialog, reassign the previously removed gesture to your scripts, then select OK.
D. Now remove a gesture from your module by replacing the gesture identifier (the key to the __gestures dictionary) with None. Save the module, restart NVDA and open Input Gestures dialog.

Expected: the gestures you removed from the module code should be removed with other gestures unaffected.
Actual: the entire gesture set for your module is listed as unassigned.

To verify:

  1. Open Python Console with the module with the removed gestures (from code) running.
  2. Type the following:
import modType (either globalPlugins or appModules)
modType.modName.modType._modType__gestures
For example:
import globalPlugins
globalPlugins.testPlugin.GlobalPlugin._GlobalPlugin__gestures

The entry with key of None is displayed first, implying that we're dealing with an ordered dictionary. This happens no matter where the None key is found - in the beginning or in the middle.

This issue has vast consequences for current and new modules:

  • Some add-ons use commands which conflicts with locale-specific gestures.ini, thus the add-on writer needs to assign unused gestures for his or her add-on (the gestures pool is decreasing).
  • Some users might assume (or assume) that add-ons come with default gesture bindings; this cannot be the case for all add-ons - an add-on writer might expect users to assign custom gestures for some commands. As a result, some writers will try to leave some scripts unassigned in their add-ons.
  • A possible solution to this issue will mean that current and new add-ons will require NVDA 2013.3 (or 2014.2/2014.3 or later) in order for gesture customization to be useful; also, if a solution to this problem is found and if an add-on writer wishes to produce an add-on with partial gesture set, then this will require future NVDA versions (add-on code compatibility issue is another story).
    Thanks.
@nvaccessAuto
Copy link
Author

Comment 1 by jteh on 2014-03-29 02:52
I haven't tested this yet. However, you should never include a key of None in the __gestures dictionary. If you don't want it assigned, simply don't list it in __gestures. It should be possible to assign a gesture to any script method as long as it has a docstring. It's possible this is broken (and this needs testing), but regardless, don't include a key of None in __gestures.

@nvaccessAuto
Copy link
Author

Comment 2 by nvdakor on 2014-03-30 00:47
Hi,
Thanks Jamie for your suggestions about removing gestures from __gestures dictionary. The code suggestion solved the problem.
For future reference, could we have a note in the dev guide regarding gestures dictionary and input gestures dialog? Thanks.

@nvaccessAuto
Copy link
Author

Comment 3 by jteh on 2014-03-30 22:03
This is not specific to the Input Gestures dialog. The Developer Guide currently states:

To bind a gesture to a script, a special "__gestures" Python dictionary can be defined as a class variable on the App Module, Global Plugin or NVDA Object.
These dictionaries should contain gesture identifier strings pointing to the name of the requested script, without the "script_" prefix.

Note the mention of "gesture identifier strings". There's no mention of "None" anywhere here. Can you clarify why this is unclear?

@nvaccessAuto
Copy link
Author

Comment 4 by nvdakor on 2014-03-30 22:14
Hi,
I think what might not be clear is that the gestures dictionary is actually optional - the guide may sound like all scripts will need gesture bindings when in reality this is optional. Partly because of the fact that examples shows that scripts are bound the gestures.
The "None" came from my experiments.
Thanks.

@nvaccessAuto
Copy link
Author

Comment 5 by jteh on 2014-03-30 22:23
Changes:
Changed title from "Input Gestures dialog: modules with partial gesture assignments fails to show assigned gestures" to "Developer Guide: Clarify how to leave scripts unbound in ScriptableObject.__gestures"

@bhavyashah
Copy link

Any updates? @jcsteh @josephsl

@josephsl
Copy link
Collaborator

josephsl commented Aug 2, 2017 via email

@Adriani90
Copy link
Collaborator

@josephsl I think this is addressed in a newer developer guide version. Or not?

@josephsl
Copy link
Collaborator

josephsl commented Dec 23, 2018 via email

@Adriani90
Copy link
Collaborator

Adriani90 commented Dec 23, 2018 via email

@ehollig
Copy link
Collaborator

ehollig commented Dec 24, 2018

Closing

@ehollig ehollig closed this as completed Dec 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants