From ef9fd6c2863fb393b422675d8121293c98e44f51 Mon Sep 17 00:00:00 2001 From: Karol Baraniecki Date: Mon, 26 Dec 2022 17:07:00 +0100 Subject: [PATCH] Calculator: Fix which digits get animated when pressing keyboard keys Previously every digit press would appear like "0" was pressed on the keypad. --- Userland/Applications/Calculator/CalculatorWidget.cpp | 3 ++- Userland/Applications/Calculator/Keypad.cpp | 3 +-- Userland/Applications/Calculator/Keypad.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/Calculator/CalculatorWidget.cpp b/Userland/Applications/Calculator/CalculatorWidget.cpp index 6f2cc8b5ab..c1129e5e07 100644 --- a/Userland/Applications/Calculator/CalculatorWidget.cpp +++ b/Userland/Applications/Calculator/CalculatorWidget.cpp @@ -159,7 +159,8 @@ void CalculatorWidget::keydown_event(GUI::KeyEvent& event) m_keypad.set_value(m_calculator.finish_operation(m_keypad.value())); mimic_pressed_button(m_equals_button); } else if (event.code_point() >= '0' && event.code_point() <= '9') { - auto const digit = m_keypad.type_digit(event.code_point() - '0'); + auto const digit = event.code_point() - '0'; + m_keypad.type_digit(digit); mimic_pressed_button(m_digit_button[digit]); } else if (event.code_point() == '.') { m_keypad.type_decimal_point(); diff --git a/Userland/Applications/Calculator/Keypad.cpp b/Userland/Applications/Calculator/Keypad.cpp index b89e0f5d2e..c116c02580 100644 --- a/Userland/Applications/Calculator/Keypad.cpp +++ b/Userland/Applications/Calculator/Keypad.cpp @@ -12,7 +12,7 @@ #include #include -unsigned Keypad::type_digit(int digit) +void Keypad::type_digit(int digit) { switch (m_state) { case State::External: @@ -34,7 +34,6 @@ unsigned Keypad::type_digit(int digit) m_frac_length.set_to(m_frac_length.plus(1)); break; } - return m_frac_length.to_u64(); } void Keypad::type_decimal_point() diff --git a/Userland/Applications/Calculator/Keypad.h b/Userland/Applications/Calculator/Keypad.h index 0106eb88c9..62a993a76d 100644 --- a/Userland/Applications/Calculator/Keypad.h +++ b/Userland/Applications/Calculator/Keypad.h @@ -21,7 +21,7 @@ public: Keypad() = default; ~Keypad() = default; - unsigned type_digit(int digit); + void type_digit(int digit); void type_decimal_point(); void type_backspace();