-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Make lesson text selectable and searchable #68
Comments
Copy pasting is prevented by the browser sandboxing webgl applications, but we can probably work around it with a custom js interface. Searching is going to be less simple to handle, because there isn't a way to arbitrarily read all text on screen in a Godot app. We'd have to register each text box individually in some repository, so we can have global search. Searching in the text editor itself (or in any individual text box) is doable, but of limited ussefulness |
So after looking into it, it doesn't seem like copy-pasting has a good solution. You can invoke methods to copy to the clipboard and intercept requests to paste from Javascript. They are relatively reliable. But that is useless because any key press and/or event gets swallowed as long as the WebGL has focus. So we cannot use those, we have to rely on native browser functionality. Note: Copy works by default in both Chrome and Firefox; however, pasting is sandboxed to the webgl context: you can copy and paste text within the app, but you can not paste text from outside the app. In Chromium, pasting an external clipboard prompts a permission request, after which pasting works. In Firefox, there's nothing to be done. Relevant references:
Open for a far fetched mitigation ideaOn way I can imagine to work around this would be to trap focus in an html element, and then forward all key presses to the WebGL context. This way, we get as much control as the browser gives us. I don't know if that would mean delays in sending keypresses though (it'd be at the very least a 1 frame delay), as well as other potential bugs. More importantly, it would become impossible to use Godot's Input system, we'd have to create our own abstraction. I'm deeming copy-paste unsolvable at the moment. I'll leave this open while we investigate the feasibility of an app-wide search functionality. |
It'd be good to have that. For now yes, it seems we can't offer copy-paste support in all browsers. Instead, for GitHub issues, we could add a more powerful feature from the app: directly create an issue with the selected text quoted. That way, you don't need copy and paste. That's a possible workaround for this issue. Searching itself is easy, but highlighting matches is not possible right now in Godot with how RichTextLabel works. We'll look into contributing to the engine to allow for that (we had to make changes engine-side for the code editor already). |
Would it be an option to have a "Paste" button? It is not ideal, but would be better than nothing. It would call out to javascript to open a focussed popup (html) which prompts the user to paste. Once the user does so, the popup closes and forwards the paste to the game instance (and returns focus/control to it). As an example to how this can look, here is how jupyter notebooks allow pasting when no text box is selected: |
I don't know if we can do that with a Godot app. Maybe. I'm not fond of those kinds of hacks and would prefer a clearer UX. Considering the problem at hand, I think the ability to report the selected text to GitHub would be simpler and clearer for the user (e.g. select, right click, report issue). We had the idea of allowing people to report and prefill issues right from the app. |
If we want pasting, the solution that Winston proposes is probably pragmatically the best solution. It isn't difficult to do, and we can invoke it from Godot without issues, whether through a button, a shortcut, or both. I suggest to split this issue in 3:
|
Sure, the thing is there's currently no issue raising the need for pasting text from outside the app into the app. And it wasn't the purpose of this issue. |
This is also required for students who work with text-to-speech and translation software. |
I think blind people won't be able to use the app. It's running in a WebGL context so we don't have access to the browser's accessibility features like aria hints. I'm unsure whether an external program could read the text inside the app. For translation, it'll be limited too. At best selection will happen per text control - you won't be able to select the entire page. There again because it's not a web page and controls work independently. But for those persons, we plan to support multiple languages, see #22 |
I wasn't primarily thinking of blind people - that kind of support would be on a completely different level. I have students who see perfectly well but still have trouble reading. They might have dyslexia, ADHD or other conditions, some have moved from other countries and are not yet fluent in the local language but are learning it, and some simply lack practice reading (as is common for teenagers these days). They use various different programs to aid them, including but not limited to TTS and translation. If they can copy text into those programs then they can use them and it improves their learning rate, and it also satisfies certain requirements in the local school system. |
I'd say this simple change on the
|
Ah it makes sense, thanks. Well, they'll likely have to use the desktop version of the app or the Chrome browser, as other browsers don't allow copying text out of the app at the moment. Regarding selecting, we need to change Godot and might as well wait until we port the app to Godot 4, got some tax change that makes a big difference for us, we have to be careful with money now. |
Is your feature request related to a problem? Please describe.
I can't select and copy any lesson text from the running app.
Describe the solution you'd like
Being able to select and copy text like in a pdf or web application.
Being able to hit Ctrl+F to search for any word of phrase and cycle through the occurances (like in any text editor or browser or pdf reader)
Why?
To report issues more easily, to quote and communicate with fellow students and teachers more easily about things which are unclear to them.
The text was updated successfully, but these errors were encountered: