Calculator: Accept more keyboard input (#1207)

Allow user to clear/remove last numeral from input (Esc/Backspace
respectively) and type the decimal point.
This commit is contained in:
ignas-sa 2020-02-10 20:48:52 +02:00 committed by GitHub
parent 077ef556a7
commit b67035c3ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: sideshowbarker 2024-07-19 09:27:41 +09:00

View file

@ -236,6 +236,16 @@ void CalculatorWidget::keydown_event(GUI::KeyEvent& event)
} else if (event.key() >= KeyCode::Key_0 && event.key() <= KeyCode::Key_9) {
m_keypad.type_digit(atoi(event.text().characters()));
} else if (event.key() == KeyCode::Key_Period) {
m_keypad.type_decimal_point();
} else if (event.key() == KeyCode::Key_Escape) {
m_keypad.set_value(0.0);
m_calculator.clear_operation();
} else if (event.key() == KeyCode::Key_Backspace) {
m_keypad.type_backspace();
} else {
Calculator::Operation operation;
@ -263,4 +273,4 @@ void CalculatorWidget::keydown_event(GUI::KeyEvent& event)
}
update_display();
}
}