8000 text_input documentation improvements on by default, needed for pygame.TEXTINPUT · Pull Request #2333 · pygame/pygame · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

text_input documentation improvements on by default, needed for pygame.TEXTINPUT #2333

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

Merged
merged 1 commit into from Nov 17, 2020
Merged

text_input documentation improvements on by default, needed for pygame.TEXTINPUT #2333

merged 1 commit into from Nov 17, 2020

Conversation

ghost
Copy link
@ghost ghost commented Nov 17, 2020

While trying the new pygame.TEXTINPUT events, I found some things in the docs that I thought could be improved...
The pygame docs says that "normal" pygame.TEXTINPUT events are not dependent on start_text_input() and stop_text_input(), but they are according to the SDL docs.

This function will start accepting Unicode text input events in the focused SDL window, and start emitting SDL_TEXTINPUT and SDL_TEXTEDITING events.

https://wiki.libsdl.org/SDL_StartTextInput

Testing shows that normal pygame.TEXTINPUT events will stop when pygame.key.stop_text_input() is called, but the whole SDL TextInput thing is on by default, so there is no need to call start_text_input() for them to work.

Everything also works in the textinput.py example file when pygame.key.start_text_input() is removed.

But I don't understand much about the advanced TEXTEDITING / IME stuff... perhaps there's something I missed.

Thanks 😄

@ghost ghost added docs key pygame.key labels Nov 17, 2020
@robertpfeiffer
Copy link
Contributor
robertpfeiffer commented Nov 17, 2020

This is probably related to key.unicode emulation, and how we document this depends on whether we want to tell users that going forward, you shouldn't use key.unicode and use TEXTINPUT events instead, or whether we want to support not only key.unicode into all eternity, but also the mixing of key.unicode and start_text_input(). My opinion on this is pretty clear. I wish there was a way to turn backwards compatibility features like key.unicode emulation off, or to issue a warning when backwards compatibility features are used intermingled with new APIs.

If you don't run your games on an Android tablet or a Touchscreen PC with an on-screen keyboard (recent Ubuntu versions work really well in this configuration), you don't need to care about this, but I do so I do.

So I'd propose documenting the current behaviour, and probably also turning off key.unicode emulation once pygame.key.stop_text_input() or pygame.key.start_text_input() are called.

I realise the documentation part is a no-brainer, and the stopping emulation part is highly contentious. But once you use pygame.key.stop_text_input(), you are using a new pygame 2.0 API, and you explicitly demarcate text input (as opposed to keyboard controls), so you don't need TEXTINPUT events outside of the demarcated sections, and you don't key.unicode emulation.

@robertpfeiffer
Copy link
Contributor

I realise I didn't explicitly comment on this pull request: In its current form, I don't think this enough.

We should document what pygame.key.start_text_input() and pygame.key.stop_text_input() actually do on desktop environments like windows, GNOME, android, and mac os, and what kind of behaviour you can expect with different languages (human languages, not programming languages).

There are two parts to this:

  1. When text editing starts and no keyboard is attached (on Windows 10, Android and Gnome 3 (Wayland or X11) at least), an on-screen-keyboard is displayed for the duration of the text editing. The on-screen keyboard might be displayed even when a physical keyboard is attached.

  2. When your locale is set to a language with complex non-Latin glyphs, and you set the editing area with SDL2, a button might be shown near the text area to open an IME on even desktop platforms with a physical keyboard attached. IME is pretty simple with the latin alphabet, but it's also supposed to allow entering CJK glyphs when your locale is set to such a language, even when your keyboard is non-CJK like QWERTY or Dvorak. I have no idea how such an IME looks, but supposedly it can be a text field rendered by the OS that lets you enter pinyin or romanji with your QWERTY keyboard, which then sends the converted CJK glyphs to the game, or a nested menu to select a gyph, or handwriting recognition. I think for Chinese, pinyin is the most common, but this system is meant to be pluggable.

We probably also need some example code and a screenshot of how both this works, and expose all of the necessary functionality properly. I know PyGame currently does the on-screen keyboard part properly (so this should be mentioned in the docs), but may be struggling with the IME part, but in this case we should aim to fix IME instead and mention that IME might currently be broken, not remove all mentions of IME from the docs.

Copy link
Member
@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks.

@illume illume merged commit 211a592 into pygame:main Nov 17, 2020
@ghost
Copy link
Author
ghost commented Nov 17, 2020

I must say I'm a bit confused that the pr was merged, because after reading your comment I agree that some information could be added... oh well 🤔

I know PyGame currently does the on-screen keyboard part properly (so this should be mentioned in the docs), but may be struggling with the IME part, but in this case we should aim to fix IME instead and mention that IME might currently be broken, not remove all mentions of IME from the docs.

That was not my intention... I mainly wanted to remove the part that said that the normal pygame.TEXTINPUT events were not dependent on start_text_input() and stop_text_input(), because they clearly are (perhaps the confusion was caused by the fact that it's on by default in the SDL)

But you're right that a lot more information could be added. I can't, unfortunately, test much of the IME stuff for now (I'm using a mac and it's not working... #2328 ) edit: Maybe the accent menu and IME stuff are separate things? I don't much about all this, I should test it more...

@illume illume changed the title text_input on by default, needed for pygame.TEXTINPUT text_input documentation improvements on by default, needed for pygame.TEXTINPUT Dec 23, 2020
@illume illume added this to the 2.0.1 milestone Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs key pygame.key
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0