mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
Calculator: Avoid focusing any keypad button other than the equal button
Having the return key sometimes press the equal button when nothing is focused and press a different button when there is focus felt confusing. The equal button is still able to be focused for the tab cycle to have something to go to in order to jump out of the textbox but no other keypad button can be focused now.
This commit is contained in:
parent
0d0ba375e2
commit
19f80f88bf
2 changed files with 26 additions and 4 deletions
|
@ -160,10 +160,6 @@ void CalculatorWidget::update_display()
|
||||||
|
|
||||||
void CalculatorWidget::keydown_event(GUI::KeyEvent& event)
|
void CalculatorWidget::keydown_event(GUI::KeyEvent& event)
|
||||||
{
|
{
|
||||||
//Clear button selection when we are typing
|
|
||||||
m_equals_button->set_focus(true);
|
|
||||||
m_equals_button->set_focus(false);
|
|
||||||
|
|
||||||
if (event.key() == KeyCode::Key_Return || event.key() == KeyCode::Key_Equal) {
|
if (event.key() == KeyCode::Key_Return || event.key() == KeyCode::Key_Equal) {
|
||||||
m_keypad.set_value(m_calculator.finish_operation(m_keypad.value()));
|
m_keypad.set_value(m_calculator.finish_operation(m_keypad.value()));
|
||||||
mimic_pressed_button(m_equals_button);
|
mimic_pressed_button(m_equals_button);
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
fixed_width: 65
|
fixed_width: 65
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "brown"
|
foreground_color: "brown"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
fixed_width: 56
|
fixed_width: 56
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "brown"
|
foreground_color: "brown"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -56,6 +58,7 @@
|
||||||
fixed_width: 60
|
fixed_width: 60
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "brown"
|
foreground_color: "brown"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +71,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "red"
|
foreground_color: "red"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Widget {
|
@GUI::Widget {
|
||||||
|
@ -80,6 +84,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -88,6 +93,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -96,6 +102,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -103,6 +110,7 @@
|
||||||
text: "/"
|
text: "/"
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -111,6 +119,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +132,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "red"
|
foreground_color: "red"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Widget {
|
@GUI::Widget {
|
||||||
|
@ -135,6 +145,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -143,6 +154,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -151,6 +163,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -158,6 +171,7 @@
|
||||||
text: "*"
|
text: "*"
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -166,6 +180,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,6 +193,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "red"
|
foreground_color: "red"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Widget {
|
@GUI::Widget {
|
||||||
|
@ -190,6 +206,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -198,6 +215,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -206,6 +224,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -213,6 +232,7 @@
|
||||||
text: "-"
|
text: "-"
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -221,6 +241,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +254,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "red"
|
foreground_color: "red"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Widget {
|
@GUI::Widget {
|
||||||
|
@ -245,6 +267,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -253,6 +276,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -261,6 +285,7 @@
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
foreground_color: "blue"
|
foreground_color: "blue"
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
@ -268,6 +293,7 @@
|
||||||
text: "+"
|
text: "+"
|
||||||
fixed_width: 35
|
fixed_width: 35
|
||||||
fixed_height: 28
|
fixed_height: 28
|
||||||
|
focus_policy: "NoFocus"
|
||||||
}
|
}
|
||||||
|
|
||||||
@GUI::Button {
|
@GUI::Button {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue