mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:17:44 +00:00
LibGUI: Support typing to search for ComboBox
LibGUI: Fixup missing one charactor issue
This commit is contained in:
parent
247951e09c
commit
6453f74642
1 changed files with 10 additions and 1 deletions
|
@ -25,6 +25,7 @@ class ComboBoxEditor final : public TextEditor {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Function<void(int delta)> on_mousewheel;
|
Function<void(int delta)> on_mousewheel;
|
||||||
|
Function<void(KeyEvent& event)> on_keypress;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ComboBoxEditor()
|
ComboBoxEditor()
|
||||||
|
@ -46,8 +47,10 @@ private:
|
||||||
if (is_focused())
|
if (is_focused())
|
||||||
set_focus(false);
|
set_focus(false);
|
||||||
event.accept();
|
event.accept();
|
||||||
} else
|
} else {
|
||||||
|
on_keypress(event);
|
||||||
TextEditor::keydown_event(event);
|
TextEditor::keydown_event(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,6 +89,12 @@ ComboBox::ComboBox()
|
||||||
if (only_allow_values_from_model())
|
if (only_allow_values_from_model())
|
||||||
m_open_button->click();
|
m_open_button->click();
|
||||||
};
|
};
|
||||||
|
m_editor->on_keypress = [this](KeyEvent& event) {
|
||||||
|
if (!m_list_window->is_visible() && event.key() <= Key_Z && event.key() >= Key_A) {
|
||||||
|
open();
|
||||||
|
m_list_window->event(event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
m_open_button = add<Button>();
|
m_open_button = add<Button>();
|
||||||
m_open_button->set_button_style(Gfx::ButtonStyle::ThickCap);
|
m_open_button->set_button_style(Gfx::ButtonStyle::ThickCap);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue