From 19f80f88bfe29fccc3f217f8c9bdf6ab8480efa5 Mon Sep 17 00:00:00 2001 From: ForLoveOfCats Date: Tue, 1 Feb 2022 18:48:24 -0500 Subject: [PATCH] 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. --- .../Calculator/CalculatorWidget.cpp | 4 --- .../Calculator/CalculatorWindow.gml | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Userland/Applications/Calculator/CalculatorWidget.cpp b/Userland/Applications/Calculator/CalculatorWidget.cpp index b1bc8e3c51..8b262e62c8 100644 --- a/Userland/Applications/Calculator/CalculatorWidget.cpp +++ b/Userland/Applications/Calculator/CalculatorWidget.cpp @@ -160,10 +160,6 @@ void CalculatorWidget::update_display() 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) { m_keypad.set_value(m_calculator.finish_operation(m_keypad.value())); mimic_pressed_button(m_equals_button); diff --git a/Userland/Applications/Calculator/CalculatorWindow.gml b/Userland/Applications/Calculator/CalculatorWindow.gml index 40972e6274..fed5dea3d3 100644 --- a/Userland/Applications/Calculator/CalculatorWindow.gml +++ b/Userland/Applications/Calculator/CalculatorWindow.gml @@ -40,6 +40,7 @@ fixed_width: 65 fixed_height: 28 foreground_color: "brown" + focus_policy: "NoFocus" } @GUI::Button { @@ -48,6 +49,7 @@ fixed_width: 56 fixed_height: 28 foreground_color: "brown" + focus_policy: "NoFocus" } @GUI::Button { @@ -56,6 +58,7 @@ fixed_width: 60 fixed_height: 28 foreground_color: "brown" + focus_policy: "NoFocus" } } @@ -68,6 +71,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "red" + focus_policy: "NoFocus" } @GUI::Widget { @@ -80,6 +84,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -88,6 +93,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -96,6 +102,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -103,6 +110,7 @@ text: "/" fixed_width: 35 fixed_height: 28 + focus_policy: "NoFocus" } @GUI::Button { @@ -111,6 +119,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } } @@ -123,6 +132,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "red" + focus_policy: "NoFocus" } @GUI::Widget { @@ -135,6 +145,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -143,6 +154,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -151,6 +163,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -158,6 +171,7 @@ text: "*" fixed_width: 35 fixed_height: 28 + focus_policy: "NoFocus" } @GUI::Button { @@ -166,6 +180,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } } @@ -178,6 +193,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "red" + focus_policy: "NoFocus" } @GUI::Widget { @@ -190,6 +206,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -198,6 +215,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -206,6 +224,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -213,6 +232,7 @@ text: "-" fixed_width: 35 fixed_height: 28 + focus_policy: "NoFocus" } @GUI::Button { @@ -221,6 +241,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } } @@ -233,6 +254,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "red" + focus_policy: "NoFocus" } @GUI::Widget { @@ -245,6 +267,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -253,6 +276,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -261,6 +285,7 @@ fixed_width: 35 fixed_height: 28 foreground_color: "blue" + focus_policy: "NoFocus" } @GUI::Button { @@ -268,6 +293,7 @@ text: "+" fixed_width: 35 fixed_height: 28 + focus_policy: "NoFocus" } @GUI::Button {