extension keybinding and custom.js

56 views
Skip to first unread message

Thierry Parmentelat

unread,
Sep 15, 2017, 3:24:59 AM9/15/17
to Project Jupyter
hi jupyter

I have a question regarding the RISE extension, but I feel like it's a general pattern for all extensions

in a nutshell, this extension offers one function for starting the slideshow

by default this function is bound to Alt-R right in the RISE code, and right now there is no convenient way to let a user customize this binding in her custom.js, because the function name is local to the extension module

I'd like to solve that cleanly, and have considered a few angles

* accessing the extension module with define()

I mean, instead of having custom.js do just this:
define(['base/js/namespace' ], function(Jupyter) { ....

it would be cool if I could do something like this
define(['base/js/namespace', 'nbextensions/rise/main' ], function(Jupyter, RISE) {

but that won't work as is; I'm not 100% clear on how these paths get searched, but on my mac at least the extensions get installed in a different location as the core code, it's probably why..

* I'm not sure about the mechanisms offered by a keyboard manager;
if this included retrieving a function in the manager from some sort of a logical name (quickly reading the code suggests there is, but it's unclear how to use this..), then the extension could register the shortcut (right now this key binding is done using a low-level mechanism), and custom.js could retrieve the function from there

===
So my questions are:

* is there some general framework that an extension should follow and that would solve this ?

* if not, is any of the 2 ideas above worth pursuing ?


thanks in advance

Jason Grout

unread,
Sep 15, 2017, 8:34:34 AM9/15/17
to Project Jupyter
I'm not sure about the answers for the classic notebook, but just wanted to point out that customizing keyboard shortcuts is possible in JupyterLab by default in the settings. The RISE extension (or other slideshow extension) hasn't been ported over yet, though.

Jason


--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/29ff18ea-d38b-4868-8e31-ded609229159%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas Kluyver

unread,
Sep 15, 2017, 8:37:27 AM9/15/17
to Project Jupyter
Hi Thierry,

On 15 September 2017 at 08:24, Thierry Parmentelat <thierry.p...@gmail.com> wrote:
by default this function is bound to Alt-R right in the RISE code, and right now there is no convenient way to let a user customize this binding in her custom.js, because the function name is local to the extension module

From our perspective, I think the answer here is for RISE to define an 'action' which is registered with the notebook, and bind the keyboard shortcut to that. Then the user can add their own shortcuts for the action. I think that should even make it show up in the 'edit shortcuts' dialog inside the notebook.
 
it would be cool if I could do something like this
define(['base/js/namespace', 'nbextensions/rise/main' ], function(Jupyter, RISE) {

but that won't work as is; I'm not 100% clear on how these paths get searched, but on my mac at least the extensions get installed in a different location as the core code, it's probably why..

I think that should work. We do something quite similar to that to load nbextensions. Not sure why it would go wrong.

Thomas

Thierry Parmentelat

unread,
Sep 15, 2017, 10:43:06 AM9/15/17
to Project Jupyter
Thanks Thomas, this is helpful, a registered action has done the trick


Reply all
Reply to author
Forward
0 new messages