Skip to content
This repository was archived by the owner on Jan 2, 2025. It is now read-only.

"printable" key handlers trigger twice #55

Closed
abesto opened this issue May 24, 2019 · 3 comments
Closed

"printable" key handlers trigger twice #55

abesto opened this issue May 24, 2019 · 3 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?

@tomassedovic
Copy link
Owner

This project has not been maintained for a few years. I'm closing all pull requests and issues before archiving the repo on github. Sorry I hadn't done this sooner!

@tomassedovic tomassedovic closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants