From 3f5313f70836eb1468738b31f31e1715cdf3e198 Mon Sep 17 00:00:00 2001 From: LaChal Date: Thu, 22 Mar 2018 22:58:05 +0100 Subject: [PATCH] Check boxes are now iterated and highlighted using 'Tab' key. It is an 'new feature', see commit #4ab20968e2a4a45db8f0dd1535084875f5336113 for activation. --- albow/controls.py | 4 ++++ albow/theme.py | 6 ++++++ albow/widget.py | 8 +++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/albow/controls.py b/albow/controls.py index c297c03e3..7f3091695 100644 --- a/albow/controls.py +++ b/albow/controls.py @@ -366,6 +366,10 @@ class CheckWidget(Widget): border_width = 1 check_mark_tweak = 2 + if __builtins__.get("mcenf_tab_to_next"): + tab_stop = True + highlight_color = ThemeProperty('highlight_color') + smooth = ThemeProperty('smooth') def __init__(self, **kwds): diff --git a/albow/theme.py b/albow/theme.py index d0977465e..18eec84f5 100644 --- a/albow/theme.py +++ b/albow/theme.py @@ -164,6 +164,12 @@ def get_font(self, cls, name): root.CheckWidget = Theme('CheckWidget') root.CheckWidget.smooth = False root.CheckWidget.border_color = root.Field.border_color +root.CheckWidget.highlight_color = (0, 128, 255) + +if __builtins__.get("mcenf_tab_to_next"): + root.CheckBox = Theme("CheckBox)") + # Let use the same highlight color as for buttons + root.CheckBox.highlight_color = root.Button.highlight_color root.Dialog = Theme('Dialog') root.Dialog.bg_color = (40, 40, 40) diff --git a/albow/widget.py b/albow/widget.py index bfcc9e10a..072252106 100644 --- a/albow/widget.py +++ b/albow/widget.py @@ -343,7 +343,13 @@ def draw_all(self, surface): self.draw(surface) bw = self.border_width if bw: - bc = self.border_color or self.fg_color + if __builtins__.get("mcenf_tab_to_next"): + if self.has_focus() and hasattr(self, "highlight_color"): + bc = self.highlight_color + else: + bc = self.border_color or self.fg_color + else: + bc = self.border_color or self.fg_color frame_rect(surface, bc, surf_rect, bw) for widget in self.subwidgets: sub_rect = widget.rect