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

Added keystrokes to the input #35

Closed

Conversation

@VictorKoenders
Copy link
Contributor

VictorKoenders commented Dec 14, 2018

When trying to make a text input component, I found out there's no way to detect what keys were pressed this tick.

The current implementation is lazy, although we might want to make this allocated since the returned iterator borrows the given Context. On the other hand, it's fairly easy to call .collect::<Vec<_>>()

I didn't think a get_key_releases method would be useful, but I'll add it if you think otherwise.

@17cupsofcoffee

This comment has been minimized.

Copy link
Owner

17cupsofcoffee commented Dec 14, 2018

This is excellent, had been meaning to get around to adding something like this :)

Couple of comments:

  • 🚲🏠: Could we call this method get_keys_pressed? I feel like that's a bit more consistent with the other methods, and I might add get_keys_down, get_keys_released, etc later on.
  • I think you might be able to simplify the implementation to ctx.input.current_key_state.difference(&ctx.input.previous_key_state). This also has the nice side effects or removing the cloning, and removing the need for the explicit lifetimes on the method.
@VictorKoenders

This comment has been minimized.

Copy link
Contributor Author

VictorKoenders commented Dec 14, 2018

On second thought, the correct way to handle text is through the Event::TextInput.

Let me close this and try something with that.

@VictorKoenders

This comment has been minimized.

Copy link
Contributor Author

VictorKoenders commented Dec 14, 2018

Let me know if you still want this PR, but I think the TextInput event supersedes this.

@17cupsofcoffee

This comment has been minimized.

Copy link
Owner

17cupsofcoffee commented Dec 14, 2018

I can think of a couple of places where this would come in handy outside of text input - that said, I'll make the above changes myself rather than making you do them, if the text input stuff is what you're mainly interested in :)

@VictorKoenders VictorKoenders mentioned this pull request Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.