mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
KeyboardMapper: Show multiple pressed keys at once
When depressing a key, KeyboardMapperWidget::keydown_event() will now update only the pressed state of the button associated with the specific key, instead of also setting the pressed state of the all the buttons to false. This makes it possible to highlight multiple pressed keys at once and makes the code more consistent; the implementation of keyup_event implied that this was a feature of the program.
This commit is contained in:
parent
a1531dba91
commit
c4b2efd95e
Notes:
sideshowbarker
2024-07-17 21:33:28 +09:00
Author: https://github.com/RasmusNylander Commit: https://github.com/SerenityOS/serenity/commit/c4b2efd95eb Pull-request: https://github.com/SerenityOS/serenity/pull/11443 Reviewed-by: https://github.com/awesomekling
@ -215,21 +215,24 @@ void KeyboardMapperWidget::save_to_file(StringView filename)
|
||||
void KeyboardMapperWidget::keydown_event(GUI::KeyEvent& event)
|
||||
{
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
if (keys[i].scancode != event.scancode())
|
||||
continue;
|
||||
auto& tmp_button = m_keys.at(i);
|
||||
tmp_button->set_pressed(keys[i].scancode == event.scancode());
|
||||
tmp_button->set_pressed(true);
|
||||
tmp_button->update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KeyboardMapperWidget::keyup_event(GUI::KeyEvent& event)
|
||||
{
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
if (keys[i].scancode == event.scancode()) {
|
||||
auto& tmp_button = m_keys.at(i);
|
||||
tmp_button->set_pressed(false);
|
||||
tmp_button->update();
|
||||
break;
|
||||
}
|
||||
if (keys[i].scancode != event.scancode())
|
||||
continue;
|
||||
auto& tmp_button = m_keys.at(i);
|
||||
tmp_button->set_pressed(false);
|
||||
tmp_button->update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user