diff --git a/docs/Configuration.md b/docs/Configuration.md index 4dc608db..eaadba1e 100644 --- a/docs/Configuration.md +++ b/docs/Configuration.md @@ -47,6 +47,12 @@ 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 +# 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 +# not recommended as the only way to control +# keyboard_navigation: False ``` !!! tip diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index c36e3971..5099c5ab 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -166,7 +166,9 @@ class KlippyGtk: def Button(self, image_name=None, label=None, style=None, scale=None, position=Gtk.PositionType.TOP, lines=2): if self.font_size_type == "max" and label is not None: image_name = None - b = Gtk.Button(hexpand=True, vexpand=True, can_focus=False, image_position=position, always_show_image=True) + 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) + b.set_can_focus(focusable) if label is not None: b.set_label(label.replace("\n", " ")) if image_name is not None: diff --git a/ks_includes/config.py b/ks_includes/config.py index f08c9da9..035b87ea 100644 --- a/ks_includes/config.py +++ b/ks_includes/config.py @@ -162,7 +162,8 @@ class KlipperScreenConfig: bools = ( 'invert_x', 'invert_y', 'invert_z', '24htime', 'only_heaters', 'show_cursor', 'confirm_estop', 'autoclose_popups', 'use_dpms', 'use_default_menu', 'side_macro_shortcut', 'use-matchbox-keyboard', - 'show_heater_power', "show_scroll_steppers", "auto_open_extrude", "start_locked" + 'show_heater_power', "show_scroll_steppers", "auto_open_extrude", "start_locked", + "keyboard_navigation" ) strs = ( 'default_printer', 'language', 'print_sort_dir', 'theme', 'screen_blanking_printing', 'font_size', diff --git a/styles/base.css b/styles/base.css index 98f09d2f..8e83314e 100644 --- a/styles/base.css +++ b/styles/base.css @@ -75,6 +75,7 @@ button { .active image, button:active, +button:focus, .button_active, button.active { background-color: @active; @@ -665,4 +666,4 @@ flowbox button { keyboard_box { padding: 0 20em; -} \ No newline at end of file +}