diff --git a/Userland/Games/GameOfLife/BoardWidget.cpp b/Userland/Games/GameOfLife/BoardWidget.cpp index 5aeaee5d47..d01780650a 100644 --- a/Userland/Games/GameOfLife/BoardWidget.cpp +++ b/Userland/Games/GameOfLife/BoardWidget.cpp @@ -196,6 +196,7 @@ void BoardWidget::paint_event(GUI::PaintEvent& event) void BoardWidget::mousedown_event(GUI::MouseEvent& event) { if (event.button() == GUI::MouseButton::Primary) { + m_dragging_enabled = (m_selected_pattern == nullptr); set_toggling_cells(true); auto row_and_column = get_row_and_column_for_point(event.x(), event.y()); if (!row_and_column.has_value()) @@ -239,7 +240,7 @@ void BoardWidget::mousemove_event(GUI::MouseEvent& event) if (!row_and_column.has_value()) return; auto [row, column] = row_and_column.value(); - if (m_toggling_cells) { + if (m_toggling_cells && m_dragging_enabled) { if (m_last_cell_toggled.row != row || m_last_cell_toggled.column != column) toggle_cell(row, column); } @@ -253,6 +254,7 @@ void BoardWidget::mousemove_event(GUI::MouseEvent& event) void BoardWidget::mouseup_event(GUI::MouseEvent&) { set_toggling_cells(false); + m_dragging_enabled = true; } Optional BoardWidget::get_row_and_column_for_point(int x, int y) const diff --git a/Userland/Games/GameOfLife/BoardWidget.h b/Userland/Games/GameOfLife/BoardWidget.h index 1b3d5431f9..77f48151d7 100644 --- a/Userland/Games/GameOfLife/BoardWidget.h +++ b/Userland/Games/GameOfLife/BoardWidget.h @@ -84,6 +84,7 @@ private: NonnullOwnPtr m_board; bool m_running { false }; + bool m_dragging_enabled { true }; int m_running_timer_interval { 500 }; int m_running_pattern_preview_timer_interval { 100 }; diff --git a/Userland/Games/GameOfLife/main.cpp b/Userland/Games/GameOfLife/main.cpp index 4216a4a38b..28513b2379 100644 --- a/Userland/Games/GameOfLife/main.cpp +++ b/Userland/Games/GameOfLife/main.cpp @@ -71,7 +71,7 @@ ErrorOr serenity_main(Main::Arguments arguments) statusbar.segment(1).set_fixed_width(ceil(width)); auto show_statusbar_hint = [&]() { - auto tip = board_widget->selected_pattern() ? pattern_place_tip : toggle_cells_tip; + auto tip = board_widget.selected_pattern() ? pattern_place_tip : toggle_cells_tip; statusbar.segment(0).set_text(tip); }; show_statusbar_hint();