-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL3 Examples source code cannot be copied with Ctrl-C #12308
Comments
I think this happens because the SDL app--specifically the canvas element, I assume--is stealing the keyboard input. You also can't bring up the developer console with F12 unless you click on the address bar first to break the keyboard focus. We might be able to do some javascript magic in the examples to steal keyboard focus when the source code and console tabs pop up, and provide it back to the canvas when they pop back down, but I have not researched this at all. |
Moving this from sdlwiki to SDL, because fixes would happen in there. |
Do you think looking at Raylib's site helps? Their example works with browsers better. |
Hmm. @Daft-Freak, how important is it that we grab the keyboard input by default? Compare: https://www.raylib.com/examples/core/loader.html?name=core_basic_screen_manager vs https://examples.libsdl.org/SDL3/renderer/01-clear/ ...and are we grabbing input too aggressively? Even when Raylib is taking keyboard input after clicking on the canvas, it still lets me use F12 to bring up the developer tools in Firefox. |
I think it was all about keyboard events working by default? (I mostly remember that getting keyboard handling to where it is took a while, and a lot of fixing one usecase breaking another.) If you only listen for keyboard events on the canvas (like by using the hint) then you need to add some JS to give the canvas focus. F12 (or any of the f-keys) is one of the keys we make sure to preventDefault on so the browser doesn't do unexpected things. Though generally we don't know what keys the user might want to handle, so we assume ALL of them. (Can override this with an event filter... I think) |
Mmm, I might revisit this and see if we can at least have a convenient way for the examples to be less grabby without adding code to the apps themselves (maybe force a hint in template.html's startup JavaScript, etc). |
The example website's source code can only be copied with right click, not Ctrl-C (or Cmd-C on macs).
The text was updated successfully, but these errors were encountered: