Skip to content
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

Reduce garbage from TextInput #6664

Merged
merged 2 commits into from
Feb 19, 2019
Merged

Reduce garbage from TextInput #6664

merged 2 commits into from
Feb 19, 2019

Conversation

mrhelmut
Copy link
Contributor

@mrhelmut mrhelmut commented Feb 16, 2019

Hey there,

This is a proposal to start addressing #6360.

It removes the string manipulations and decodes each UTF8 characters individually and sends them to the event handler.
It also skips the event processing if there is no event handler attached to GameWindow.TextInput.

This should:

  • remove all garbage if TextInput isn't used when pressing keys (which I believe is the most important fix here)
  • greatly reduce garbage when actually using TextInput

There is still some garbage generated from this line when attaching an handler to TextInput:

OnTextInput(this, new TextInputEventArgs(c, key));

We will have to figure out (in another PR?) what to do with event args types.

Also, it should be noted that this PR comes with a limitation (note that the original code also has this limitation): it doesn't support UTF8 characters that are encoded on more than 2 bytes (because TextInputEventArgs is limited by the char type). Chinese, Japanese, and Korean won't be supported.

This should be addressed in another PR I guess (at the same time as addressing the event args type?).

Partly fixes #6360

MonoGame.Framework/GameWindow.cs Outdated Show resolved Hide resolved
@harry-cpp
Copy link
Member

Thanks @mrhelmut , merging!

@harry-cpp harry-cpp merged commit d9e38a5 into MonoGame:develop Feb 19, 2019
@mrhelmut mrhelmut deleted the textinputGarbage branch February 20, 2019 07:59
@harry-cpp harry-cpp added this to the 3.8 Release milestone Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Each keystroke produces some garbage
2 participants