Tracktion / choc

A collection of header only classes, permissively licensed, to provide basic useful tasks with the bare-minimum of dependencies.
Other
529 stars 47 forks source link

cmd+c/cmd+v not working in webview (MacOs) #18

Closed rorywalsh closed 11 months ago

rorywalsh commented 1 year ago

Default keybindings for copy/paste/cut don't seem to work with the webview on MacOS. As a test you can add a simple <input type="text"> to your page. The same test works fine on Windows. Is there something special that needs to be done to enable this behaviour? I'll dig through the source to see if something obvious jumps out, perhaps it's a known issue?

cannc4 commented 1 year ago

Been having the same problem too. I think there are ways to catch the events and use clipboard helpers like writeText to handle clipboard events but obviously would be great if it was directly supported

rorywalsh commented 1 year ago

In my use case I was able to get around the issue by intercepted the key presses on the js side and passing them on to the relevant components, but it's not ideal. I keep my fingers crossed that there is a simple solution thst can be implemented on the choc::webview side. Until now this has been the only real issue I've faced with it.

julianstorer commented 1 year ago

Thanks - we'll be doing some plugin compatibility work fairly soon, and this is one of the things we'll be checking

otristan commented 1 year ago

Would be eager to get this supported so I'm trying to add this but I'm no objC expert From what I understand you need to add class_addMethod (webviewClass, sel_registerName ("performKeyEquivalent:"), in WebviewClass() ctor

and do something similar to https://stackoverflow.com/questions/970707/cocoa-keyboard-shortcuts-in-dialog-without-an-edit-menu

Any input is welcomed

Thanks !

julianstorer commented 11 months ago

OK, I've pushed a fix for this now - give it a try!

otristan commented 11 months ago

Works fine now. Thanks a lot !