diff --git a/ks_includes/widgets/keyboard.py b/ks_includes/widgets/keyboard.py index a09dccf5..fc58d299 100644 --- a/ks_includes/widgets/keyboard.py +++ b/ks_includes/widgets/keyboard.py @@ -209,7 +209,7 @@ class Keyboard(Gtk.Box): if key == "⌫": Gtk.Entry.do_backspace(self.entry) elif key == "↓": - self.close_cb() + self.close_cb(entry=self.entry) return elif key == "↑": self.toggle_shift() diff --git a/panels/gcode_macros.py b/panels/gcode_macros.py index 9465d645..10445c02 100644 --- a/panels/gcode_macros.py +++ b/panels/gcode_macros.py @@ -86,18 +86,40 @@ class Panel(ScreenPanel): if result: result = result.groupdict() default = result["default"] if "default" in result else "" - entry = Gtk.Entry(placeholder_text=default) + entry = Gtk.Entry(placeholder_text=default, input_purpose=Gtk.InputPurpose.ALPHA) + icon = self._gtk.PixbufFromIcon("hashtag") + entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon) + entry.connect("icon-press", self.on_icon_pressed) self.macros[macro]["params"].update({result["param"]: entry}) for param in self.macros[macro]["params"]: labels.add(Gtk.Label(param)) self.macros[macro]["params"][param].connect("focus-in-event", self._screen.show_keyboard) + self.macros[macro]["params"][param].connect("focus-in-event", self.scroll_to_entry) self.macros[macro]["params"][param].connect("focus-out-event", self._screen.remove_keyboard) labels.add(self.macros[macro]["params"][param]) + def scroll_to_entry(self, entry, event): + self.labels['macros_list'].get_vadjustment().set_value( + entry.get_allocation().y - 50 + ) + + def on_icon_pressed(self, entry, icon_pos, event): + entry.grab_focus() + self._screen.remove_keyboard() + if entry.get_input_purpose() == Gtk.InputPurpose.ALPHA: + entry.set_input_purpose(Gtk.InputPurpose.DIGITS) + entry.get_style_context().add_class("active") + else: + entry.set_input_purpose(Gtk.InputPurpose.ALPHA) + entry.get_style_context().remove_class("active") + self._screen.show_keyboard(entry) + def run_gcode_macro(self, widget, macro): params = "" for param in self.macros[macro]["params"]: + self.macros[macro]["params"][param].set_sensitive(False) # Move focus to prevent + self.macros[macro]["params"][param].set_sensitive(True) # reopening the osk value = self.macros[macro]["params"][param].get_text() if value: if re.findall(r'[G|M]\d{1,3}', macro): diff --git a/screen.py b/screen.py index cf66472c..9238e74e 100755 --- a/screen.py +++ b/screen.py @@ -1207,13 +1207,16 @@ class KlipperScreen(Gtk.Window): } return - def remove_keyboard(self, widget=None, event=None): + def remove_keyboard(self, entry=None, event=None): if self.keyboard is None: return if 'process' in self.keyboard: os.kill(self.keyboard['process'].pid, SIGTERM) self.base_panel.content.remove(self.keyboard['box']) self.keyboard = None + if entry: + entry.set_sensitive(False) # Move the focus + entry.set_sensitive(True) def _key_press_event(self, widget, event): keyval_name = Gdk.keyval_name(event.keyval) diff --git a/styles/base.css b/styles/base.css index 06459ba7..04519f9a 100644 --- a/styles/base.css +++ b/styles/base.css @@ -73,6 +73,7 @@ button { -gtk-icon-shadow: none; } +.active image, button:active, .button_active, button.active { @@ -166,6 +167,13 @@ entry { background-color: @active; border: .2em solid @bg; padding: .2em; + margin-right: .5em; +} + +entry image { + margin: 0 .1em; + border-radius: 1em; + padding: .5em; } label { diff --git a/styles/colorized/style.css b/styles/colorized/style.css index 428bf35b..15b7b555 100644 --- a/styles/colorized/style.css +++ b/styles/colorized/style.css @@ -32,6 +32,7 @@ button { background-color: @solarized-base03; } +.active image, button:active { background-color: @solarized-orange; } diff --git a/styles/material-dark/style.css b/styles/material-dark/style.css index 8cb9d762..58178690 100644 --- a/styles/material-dark/style.css +++ b/styles/material-dark/style.css @@ -58,6 +58,7 @@ button.color4 { border-radius: 1em; } +.active image, button.color1:active, button.color2:active, button.color3:active, diff --git a/styles/material-darker/style.css b/styles/material-darker/style.css index f58e7be3..a59d5562 100644 --- a/styles/material-darker/style.css +++ b/styles/material-darker/style.css @@ -66,6 +66,7 @@ button.invalid:active, background-color: #424242; } +.active image, button.update { color: #2196f3; background-color: #121212; diff --git a/styles/material-light/style.css b/styles/material-light/style.css index 15ba714e..daad1a7e 100644 --- a/styles/material-light/style.css +++ b/styles/material-light/style.css @@ -31,6 +31,7 @@ button label{ color: @text; } +.active image, button:active { background-color: @active; } diff --git a/styles/z-bolt/style.css b/styles/z-bolt/style.css index 7523f00e..73867f6e 100644 --- a/styles/z-bolt/style.css +++ b/styles/z-bolt/style.css @@ -58,6 +58,7 @@ button.active { background-color: @active; } +.active image, button.update { background: @color3; border-color: @color3;