mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
2048: Call event.ignore() correctly in 2048's BoardView keydown handler
This commit is contained in:
parent
66b15e6cd6
commit
a9bc626639
Notes:
sideshowbarker
2024-07-17 07:25:39 +09:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/SerenityOS/serenity/commit/a9bc626639 Pull-request: https://github.com/SerenityOS/serenity/pull/15788 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 10 additions and 6 deletions
|
@ -98,29 +98,33 @@ void BoardView::resize()
|
|||
|
||||
void BoardView::keydown_event(GUI::KeyEvent& event)
|
||||
{
|
||||
if (!on_move)
|
||||
if (!on_move) {
|
||||
event.ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.key()) {
|
||||
case KeyCode::Key_A:
|
||||
case KeyCode::Key_Left:
|
||||
on_move(Game::Direction::Left);
|
||||
break;
|
||||
return;
|
||||
case KeyCode::Key_D:
|
||||
case KeyCode::Key_Right:
|
||||
on_move(Game::Direction::Right);
|
||||
break;
|
||||
return;
|
||||
case KeyCode::Key_W:
|
||||
case KeyCode::Key_Up:
|
||||
on_move(Game::Direction::Up);
|
||||
break;
|
||||
return;
|
||||
case KeyCode::Key_S:
|
||||
case KeyCode::Key_Down:
|
||||
on_move(Game::Direction::Down);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
event.ignore();
|
||||
}
|
||||
|
||||
Gfx::Color BoardView::background_color_for_cell(u32 value)
|
||||
|
|
Loading…
Reference in a new issue