From b67035c3ac5659b26d88c91d03eda6bf19c35df3 Mon Sep 17 00:00:00 2001 From: ignas-sa <53993155+ignas-sa@users.noreply.github.com> Date: Mon, 10 Feb 2020 20:48:52 +0200 Subject: [PATCH] Calculator: Accept more keyboard input (#1207) Allow user to clear/remove last numeral from input (Esc/Backspace respectively) and type the decimal point. --- Applications/Calculator/CalculatorWidget.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Applications/Calculator/CalculatorWidget.cpp b/Applications/Calculator/CalculatorWidget.cpp index 4cf348d7d7..d986ee0eab 100644 --- a/Applications/Calculator/CalculatorWidget.cpp +++ b/Applications/Calculator/CalculatorWidget.cpp @@ -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(); -} \ No newline at end of file +}