Selaa lähdekoodia

Calculator: Accept more keyboard input (#1207)

Allow user to clear/remove last numeral from input (Esc/Backspace
respectively) and type the decimal point.
ignas-sa 5 vuotta sitten
vanhempi
commit
b67035c3ac
1 muutettua tiedostoa jossa 11 lisäystä ja 1 poistoa
  1. 11 1
      Applications/Calculator/CalculatorWidget.cpp

+ 11 - 1
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) {
     } else if (event.key() >= KeyCode::Key_0 && event.key() <= KeyCode::Key_9) {
         m_keypad.type_digit(atoi(event.text().characters()));
         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 {
     } else {
         Calculator::Operation operation;
         Calculator::Operation operation;
 
 
@@ -263,4 +273,4 @@ void CalculatorWidget::keydown_event(GUI::KeyEvent& event)
     }
     }
 
 
     update_display();
     update_display();
-}
+}