mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
GWindow: Leave SerenityKey mode if non-existent keybind is used
This commit is contained in:
parent
72264661fd
commit
053f41f4f9
4 changed files with 26 additions and 19 deletions
|
@ -64,9 +64,9 @@ void GButton::click()
|
|||
on_click(*this);
|
||||
}
|
||||
|
||||
/*bool GButton::accepts_keyboard_select() const {
|
||||
bool GButton::accepts_keyboard_select() const {
|
||||
return is_enabled();
|
||||
}*/
|
||||
}
|
||||
|
||||
void GButton::set_action(GAction& action)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
|
||||
virtual const char* class_name() const override { return "GButton"; }
|
||||
virtual bool accepts_focus() const override { return true; }
|
||||
virtual bool accepts_keyboard_select() const;
|
||||
|
||||
protected:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
|
|
|
@ -278,6 +278,7 @@ void GWindow::event(CEvent& event)
|
|||
}
|
||||
|
||||
if (m_keybind_mode) {
|
||||
if (event.type() == GEvent::KeyUp) {
|
||||
StringBuilder builder;
|
||||
//Y u no work
|
||||
builder.append(m_entered_keybind);
|
||||
|
@ -293,9 +294,12 @@ void GWindow::event(CEvent& event)
|
|||
event = make<GMouseEvent>(GEvent::MouseUp, point, 0, GMouseButton::Left, 0, 0);
|
||||
found_widget->value->event(*event);
|
||||
//Call click on the found widget
|
||||
} else if (m_entered_keybind.length() >= m_max_keybind_length) {
|
||||
m_keybind_mode = false;
|
||||
}
|
||||
//m_entered_keybind.append(keyevent.text());
|
||||
update();
|
||||
}
|
||||
} else {
|
||||
if (m_focused_widget)
|
||||
return m_focused_widget->event(event);
|
||||
|
@ -348,7 +352,8 @@ void GWindow::find_keyboard_selectable() {
|
|||
m_hashed_potential_keybind_widgets.clear();
|
||||
find_keyboard_selectable_children(m_main_widget);
|
||||
|
||||
size_t buffer_length = ceil_div(m_potential_keybind_widgets.size(), ('z'-'a'))+1;
|
||||
m_max_keybind_length = ceil_div(m_potential_keybind_widgets.size(), ('z'-'a'));
|
||||
size_t buffer_length = m_max_keybind_length + 1;
|
||||
char keybind_buffer[buffer_length];
|
||||
for (size_t i = 0; i < buffer_length-1; i++) {
|
||||
keybind_buffer[i] = 'a';
|
||||
|
|
|
@ -166,6 +166,7 @@ private:
|
|||
bool m_show_titlebar { true };
|
||||
bool m_keybind_mode { false };
|
||||
String m_entered_keybind;
|
||||
size_t m_max_keybind_length;
|
||||
Vector<GWidget*> m_potential_keybind_widgets;
|
||||
HashMap<String, GWidget*> m_hashed_potential_keybind_widgets;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue