Triggering JS callback when activating/deactivating a tool

Hello everyone,

Apologies for spamming, but I have a question regarding tools. I have got a TapTool with my personal callback. Now, I would like to trigger a different js callback (hiding and showing some lines) upon (de)activation of the plot tool. Can I do that? I was searching around and could not find a solution.

TapTool.js_on_change('active') or a js_link did not do the job.

Many thanks in advance!

active is an internal property (don’t know the reason) so you can’t really do anything with it except for direct changes.

I think you would have to create a custom tool model for this.

It doesn’t make sense for it to be user-settable, since which tools are active is coordinated at a higher level. But it well-predates the introduction of readonly properties, so at the time all that could be done was to hide it. Now that readonly properties ar ean option, we could consider adding it as such.

Ah, right.
@d-que for context, there’s also this issue:


Thanks for the infos. I also tried to do plot.toolbar.js_on_change('active_tap', callback) which probably does not work for similar reasons. Having those properties as readonly would be great. But I am not sure how widespread the usage would be (though I would appreciate it).

My workaround is to have a Button with a js_link to line visibility. Thanks for your efforts!


I’m fairly certain this is not the first time I’ve seen the ask, so FWIW I think a GitHub issue would be totally appropriate.

Hi Bryan,

I have created an issue now.

Cheers and have a great easter weekend!

1 Like