2048: Call event.ignore() correctly in 2048's BoardView keydown handler

This commit is contained in:
Zaggy1024 2022-10-25 01:09:03 -05:00 committed by Sam Atkins
parent 66b15e6cd6
commit a9bc626639
Notes: sideshowbarker 2024-07-17 07:25:39 +09:00

View file

@ -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)