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

No keyboard input for TextEdit widget #105

Open
sigurd4 opened this issue Jan 8, 2024 · 2 comments
Open

No keyboard input for TextEdit widget #105

sigurd4 opened this issue Jan 8, 2024 · 2 comments

Comments

@sigurd4
Copy link

sigurd4 commented Jan 8, 2024

I'm trying to add an interactive text box to my plugin using the TextEdit widget.

The TextBuffer::insert_text method of my text buffer never gets called and if i use ui.input(...) to check for a specific key-press it also never gets called.

It seems like egui does not receive keyboard input at all.

Do i need to do any extra preparations to enable keyboard input to the GUI? I can't find any documentation on this.

This is the code of interest inside an egui panel:

                              let mut buf = params.tuning_text_buffer.load();
                              let response = ui.add(
                                  nih_plug_egui::egui::widgets::TextEdit::singleline(&mut buf)
                                      .char_limit(TUNING_NAME_LENGTH_MAX)
                                      .interactive(true)
                              );
                              if response.changed()
                              {
                                  // Never changed
                                  params.tuning_text_buffer.store(buf);
                              }
                              if response.has_focus()
                              {
                                  ui.input(|i| if i.key_down(egui::Key::Backspace)
                                  {
                                      // Never gets called
                                      response.surrender_focus()
                                  });
                                  let mut clicked = false;
                                  ui.toggle_value(&mut clicked, "12edo");
                              }

params.tuning_text_buffer is a struct inside an Arc<AtomicCell<...>> that implements egui::TextBuffer

@JerwuQu
Copy link
Contributor

JerwuQu commented Apr 21, 2024

Also ran into this issue with text input with egui. Did you find a workaround @sigurd4?

Edit: Looks like this is an issue in the baseview library not capturing keyboard events for child windows. Related RustAudio/baseview#152.

@sigurd4
Copy link
Author

sigurd4 commented Apr 22, 2024

No, I did not find a workaround

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

2 participants