diff options
author | ignas-sa <53993155+ignas-sa@users.noreply.github.com> | 2020-02-10 20:48:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-10 19:48:52 +0100 |
commit | b67035c3ac5659b26d88c91d03eda6bf19c35df3 (patch) | |
tree | 4a90557290ef0e2e54abe562813f82442b96d21a /Applications/Calculator | |
parent | 077ef556a7da9f3a5cb67418b1eb77bc6d769d6c (diff) | |
download | serenity-b67035c3ac5659b26d88c91d03eda6bf19c35df3.zip |
Calculator: Accept more keyboard input (#1207)
Allow user to clear/remove last numeral from input (Esc/Backspace
respectively) and type the decimal point.
Diffstat (limited to 'Applications/Calculator')
-rw-r--r-- | Applications/Calculator/CalculatorWidget.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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 +} |