Update on this topic: It has now become much easier!
navigator.clipboard
is now fully supported by most modern browsers, and Anvil have exposed that functionality through the anvil.js
module. So really it’s just an import and a one-liner:
from anvil.js.window import navigator
class MyForm(MyFormTemplate):
def __init__(self, **properties):
self.init_components(**properties)
def copy_button_click(self, **event_args):
navigator.clipboard.writeText("Hello World!")