From 4fb43ff6b8313e47ca068c1619feadadcc3b14ec Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Sat, 28 Feb 2026 14:06:22 -0300 Subject: [PATCH] fix: styles for keyboard navigaton --- docs/Configuration.md | 4 ++-- ks_includes/KlippyGtk.py | 2 +- styles/base.css | 1 - styles/colorized/style.css | 15 ++++++++++++++- styles/material-dark/style.css | 16 +++++++++++++++- styles/material-darker/style.css | 16 +++++++++++++++- styles/material-light/style.css | 15 ++++++++++++++- styles/z-bolt/style.css | 3 ++- 8 files changed, 63 insertions(+), 9 deletions(-) diff --git a/docs/Configuration.md b/docs/Configuration.md index eaadba1e..10aa870e 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -48,9 +48,9 @@ The options listed here are not editable from within the user interface. # Start KlipperScreen with the screen locked # start_locked: False -# Allow the buttons to focus to navigate with the keyboard +# Allow button focus to navigate with the keyboard # a scroll wheel mapped to tab/shift+tab and enter button can work -# Beware that the UI is coded to be touchscreen controlled, this is secondary and +# Beware that the UI is coded to be touchscreen controlled, this is # not recommended as the only way to control # keyboard_navigation: False ``` diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index 5099c5ab..909b2924 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -167,7 +167,7 @@ class KlippyGtk: if self.font_size_type == "max" and label is not None: image_name = None b = Gtk.Button(hexpand=True, vexpand=True, image_position=position, always_show_image=True) - focusable = self.screen._config.get_main_config().getboolean("allow_button_focus", fallback=False) + focusable = self.screen._config.get_main_config().getboolean("keyboard_navigation", fallback=False) b.set_can_focus(focusable) if label is not None: b.set_label(label.replace("\n", " ")) diff --git a/styles/base.css b/styles/base.css index 8e83314e..084e20b6 100644 --- a/styles/base.css +++ b/styles/base.css @@ -75,7 +75,6 @@ button { .active image, button:active, -button:focus, .button_active, button.active { background-color: @active; diff --git a/styles/colorized/style.css b/styles/colorized/style.css index 15b7b555..50c0e332 100644 --- a/styles/colorized/style.css +++ b/styles/colorized/style.css @@ -68,6 +68,19 @@ button.color4 { border-radius: 1em; } +button:focus, +button.color1:focus, +button.color2:focus, +button.color3:focus, +button.color4:focus, +button.update:focus, +button.invalid:focus, +.dialog button:focus +{ + outline: .1em dashed @solarized-orange; + outline-offset: .1em; +} + button.color1:active, button.color2:active, button.color3:active, @@ -280,4 +293,4 @@ textview .time { .dialog-primary { border-bottom-color: @solarized-green; -} \ No newline at end of file +} diff --git a/styles/material-dark/style.css b/styles/material-dark/style.css index 58178690..44424df2 100644 --- a/styles/material-dark/style.css +++ b/styles/material-dark/style.css @@ -58,6 +58,20 @@ button.color4 { border-radius: 1em; } + +button:focus, +button.color1:focus, +button.color2:focus, +button.color3:focus, +button.color4:focus, +button.update:focus, +button.invalid:focus, +.dialog button:focus +{ + outline: .1em dashed @active; + outline-offset: .1em; +} + .active image, button.color1:active, button.color2:active, @@ -247,4 +261,4 @@ button.active { .dialog-primary { border-bottom-color: @color1; -} \ No newline at end of file +} diff --git a/styles/material-darker/style.css b/styles/material-darker/style.css index a59d5562..e35d092c 100644 --- a/styles/material-darker/style.css +++ b/styles/material-darker/style.css @@ -55,6 +55,20 @@ button.color4 { padding-top: 0.4em; } + +button:focus, +button.color1:focus, +button.color2:focus, +button.color3:focus, +button.color4:focus, +button.update:focus, +button.invalid:focus, +.dialog button:focus +{ + background-color: #424242; + border-color: #424242; +} + button.color1:active, button.color2:active, button.color3:active, @@ -241,4 +255,4 @@ textview .time { .keyboard_pad { background-color: #090909; -} \ No newline at end of file +} diff --git a/styles/material-light/style.css b/styles/material-light/style.css index daad1a7e..dd614328 100644 --- a/styles/material-light/style.css +++ b/styles/material-light/style.css @@ -80,6 +80,19 @@ button.color4 { border-radius: 1em; } +button:focus, +button.color1:focus, +button.color2:focus, +button.color3:focus, +button.color4:focus, +button.update:focus, +button.invalid:focus, +.dialog button:focus +{ + outline: .1em dashed @solarized-orange; + outline-offset: .1em; +} + button.color1:active, button.color2:active, button.color3:active, @@ -314,4 +327,4 @@ textview .time { .dialog-primary { background-color: @color1; border-bottom-color: @color1; -} \ No newline at end of file +} diff --git a/styles/z-bolt/style.css b/styles/z-bolt/style.css index 73867f6e..bed0f707 100644 --- a/styles/z-bolt/style.css +++ b/styles/z-bolt/style.css @@ -29,6 +29,7 @@ button { background-color: @bg; } +button:focus, button:active { background-color: @active; } @@ -216,4 +217,4 @@ textview .time { .dialog-primary { border-bottom-color: @color1; -} \ No newline at end of file +}