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

"printable" key handlers trigger twice #55

Open
abesto opened this issue May 24, 2019 · 2 comments
Open

"printable" key handlers trigger twice #55

abesto opened this issue May 24, 2019 · 2 comments

Comments

@abesto
Copy link

abesto commented May 24, 2019

Maybe easiest to reproduce by placing duplicate items during map generation, and trying to pick them up; whenever available, two items are picked up. The reason for this seems to be that tcod::input emits two events; one as a character, another as text:

Key { code: Char, printable: 'g', pressed: true, left_alt: false, left_ctrl: false, right_alt: false, right_ctrl: false, shift: false, alt: false, ctrl: false, text: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
Key { code: Text, printable: 'g', pressed: true, left_alt: false, left_ctrl: false, right_alt: false, right_ctrl: false, shift: false, alt: false, ctrl: false, text: [103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }

The solution seems to be simple: extend the match patterns to include code: Char.

@abesto
Copy link
Author

abesto commented May 25, 2019

This might also explain #54, possibly (Char event triggers, is handled by the menu handler, then the Text even triggers, which is then handled by the main input handler)

@abesto
Copy link
Author

abesto commented Jun 6, 2019

Huh, according to https://bitbucket.org/libtcod/libtcod/pull-requests/76/set-key-c-0-on-textinput-events/diff this is caused by a problem in libtcod that was fixed in 1.6.5. I guess upgrading tcod-rs from 1.6.3 might help fix this properly?

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

No branches or pull requests

1 participant