1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:07:36 +00:00

Calculator: Fix which digits get animated when pressing keyboard keys

Previously every digit press would appear like "0" was pressed on the
keypad.
This commit is contained in:
Karol Baraniecki 2022-12-26 17:07:00 +01:00 committed by Andreas Kling
parent c65df44eee
commit ef9fd6c286
3 changed files with 4 additions and 4 deletions

View file

@ -159,7 +159,8 @@ void CalculatorWidget::keydown_event(GUI::KeyEvent& event)
m_keypad.set_value(m_calculator.finish_operation(m_keypad.value())); m_keypad.set_value(m_calculator.finish_operation(m_keypad.value()));
mimic_pressed_button(m_equals_button); mimic_pressed_button(m_equals_button);
} else if (event.code_point() >= '0' && event.code_point() <= '9') { } 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]); mimic_pressed_button(m_digit_button[digit]);
} else if (event.code_point() == '.') { } else if (event.code_point() == '.') {
m_keypad.type_decimal_point(); m_keypad.type_decimal_point();

View file

@ -12,7 +12,7 @@
#include <LibCrypto/BigInt/UnsignedBigInteger.h> #include <LibCrypto/BigInt/UnsignedBigInteger.h>
#include <LibCrypto/NumberTheory/ModularFunctions.h> #include <LibCrypto/NumberTheory/ModularFunctions.h>
unsigned Keypad::type_digit(int digit) void Keypad::type_digit(int digit)
{ {
switch (m_state) { switch (m_state) {
case State::External: case State::External:
@ -34,7 +34,6 @@ unsigned Keypad::type_digit(int digit)
m_frac_length.set_to(m_frac_length.plus(1)); m_frac_length.set_to(m_frac_length.plus(1));
break; break;
} }
return m_frac_length.to_u64();
} }
void Keypad::type_decimal_point() void Keypad::type_decimal_point()

View file

@ -21,7 +21,7 @@ public:
Keypad() = default; Keypad() = default;
~Keypad() = default; ~Keypad() = default;
unsigned type_digit(int digit); void type_digit(int digit);
void type_decimal_point(); void type_decimal_point();
void type_backspace(); void type_backspace();