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

Characters sent to input text are being repeated #776

Open
juliusl opened this issue May 2, 2024 · 3 comments
Open

Characters sent to input text are being repeated #776

juliusl opened this issue May 2, 2024 · 3 comments

Comments

@juliusl
Copy link
Contributor

juliusl commented May 2, 2024

Describe the bug
A clear and concise description of what the bug is.

On the main branch, when typing into an input text, the characters are being repeated.

Env

  • winit 0.29.0, wayland

Other information
Add related issues, suggestions about how to fix, any other context here.

It looks like the issues is because in winit 0.29.0 they removed the ReceivedCharacter event, so now imgui-winit-support calls add_input_character inside of KeyboardInput.

I think the problem is that the KeyboardInput event is emitted twice (press/release) which means add_input_character is going to be called twice.

@juliusl
Copy link
Contributor Author

juliusl commented May 2, 2024

Tried a fix and seems to work,

 WindowEvent::KeyboardInput { ref event, .. } => {
                if let Some(txt) = &event.text {
                    if event.state.is_pressed() {
                        for ch in txt.chars() {
                            if ch != '\u{7f}' {
                                io.add_input_character(ch)
                            }
                        }
                    }
                }

Helyos96 added a commit to Helyos96/Lightning that referenced this issue May 10, 2024
Note that due to a bug in imgui-rs 0.12, characters repeat on text
input..

imgui-rs/imgui-rs#776
Helyos96 added a commit to Helyos96/Lightning that referenced this issue May 10, 2024
Note that due to a bug in imgui-rs 0.12, characters repeat on text
input.

imgui-rs/imgui-rs#776
@Helyos96
Copy link

Happening on X11 here, but Windows is fine.

@filnet
Copy link
Contributor

filnet commented May 29, 2024

nit: in the proposed fix, the is pressed check should be done before extracting the event text.

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

3 participants