-
Notifications
You must be signed in to change notification settings - Fork 64
The oncopy, oncut, onpaste events don't occur #125
Comments
It seems like this isn't implemented in |
We encounter the same issue at work. It seems like the SDL2 keydown event is supressing the other events from being triggered (by calling var original_addEventListener = window.addEventListener;
window.addEventListener = function (type, handler, opts)
{
if (type === "keyup" || type === "keydown" || type === "keypress")
{
original_addEventListener(type, function (e) {
let key = e.which || e.keyCode;
let ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false);
if (ctrl && (key == 86 || key == 67 || key == 88))
return false;
handler(e);
}, opts);
}
else
{
original_addEventListener(type, handler, opts);
}
};
window.addEventListener("paste", (event) => {
event.preventDefault();
let pastedText = (event.clipboardData || window.clipboardData).getData('text');
alert(pastedText);
}, true);
.... Issue with this is approach is that it doesn't work for all platforms (e.g. not the command key on macOS) and that it's super hacky to do that manually. A portable solution on the SDL2 port would be great. |
Hmm I accidentally broke this in 993758c, which was to fix stuff like Ctrl-R refreshing the page. Not sure how best to fix this... If you don't need to paste onto the canvas, |
@Daft-Freak We want to use the default SDL key event handling preferably. Maybe |
Ah, yeah I haven't looked at implementing SDL's clipboard support. I think it may be a bit of an API mismatch... |
@Daft-Freak yeah i noticed that aswell. But why is it necessary that the keypress event handlers prevent the default behaviour, which causes the copy / cut / paste events not being called at all on the JavaScript part? |
Mainly for keys like backspace, where the default action is unexpected for the app. Also, consistency with the other event handlers. (The |
Hello.
I used the simple example: http://main.lv/writeup/web_assembly_sdl_example.md
Also, I added in index.html:
I used - "Press CTRL + X", "Press CTRL + C", "Press CTRL + V"
The event 'keydown' occurs. But the events 'copy', 'cut', 'paste' events don't occur.
I canceled this changes: 993758c. That helped me.
The text was updated successfully, but these errors were encountered: