Copy to clipboard functionality

We have copy to clipboard functionality in bokehjs but it resides under save tools in context menu as shown in image below:

and explained in : Add support for copying canvas to clipboard by mattpap · Pull Request #10066 · bokeh/bokeh · GitHub

Is there a way to display the copy to clipboard tool out of save tool’s context menu?

if not how can i create a custom action with copy to clipboard functionality ?

@adamwarlock you could either:

  • Add a Button outside the plot, or
  • Add a CustomAction to get a toolbar icon

Either way, you would have a few lines of JS code that mimic what the existing SaveTool does for copying to the clipboard:

It will be easier to help you if you can share what code you have already attempted.

I would love to see a copy tool beside the save tool. Copy/Paste is easily as common and useful a tool as saving is IMHO.

@bernd-wechner As pointed out in this StackOverflow answer copy-paste APIs for HTML canvas as experimental at best, only in some browsers, and non-existent in most browsers. I would not expect a “native copy” solution anytime soon. (I.e the save tool, or more generally, a “button” of some sort with a JS callback, is the best that is possible currently)

We already have such tool (though it’s a mode of the save tool, not a tool on its own; this will change in bokeh 3.0). You can use the tool by pressing on save tool’s icon and clicking on copy to clipboard item in the context menu. The menu will not appear if copy to clipboard functionality is not available in the web browser (e.g. Firefox needs a configuration flag to be set to enable this feature, see Clipboard API - Web APIs | MDN).

In bokeh 3.0 we will make “copy to clipboard” (and others) proper tools, so one will be able to configure toolbars the way they want.

@mateusz unless I am misunderstanding, that is still not “Crtrl-C to copy”, which is the ask, as far as I can tell.