robbert-vdh / nih-plug

Rust VST3 and CLAP plugin framework and plugins - because everything is better when you do it yourself

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No keyboard input for TextEdit widget

sigurd4 opened this issue · comments

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

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.

No, I did not find a workaround