mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
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:
parent
077ef556a7
commit
b67035c3ac
1 changed files with 11 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue