diff --git a/ks_includes/widgets/keyboard.py b/ks_includes/widgets/keyboard.py
index 28f3fedb..a2c1b1a7 100644
--- a/ks_includes/widgets/keyboard.py
+++ b/ks_includes/widgets/keyboard.py
@@ -19,11 +19,12 @@ class Keyboard(Gtk.Box):
self.keyboard.set_direction(Gtk.TextDirection.LTR)
self.timeout = self.clear_timeout = None
self.entry = entry
+ self.purpose = self.entry.get_input_purpose()
language = self.detect_language(screen._config.get_main_config().get("language", None))
logging.info(f"Keyboard {language}")
- if self.purpose_is_digits():
+ if self.purpose == Gtk.InputPurpose.DIGITS:
self.keys = [
[
["7", "8", "9"],
@@ -32,6 +33,15 @@ class Keyboard(Gtk.Box):
["↓", "0", "⌫"]
]
]
+ elif self.purpose == Gtk.InputPurpose.NUMBER:
+ self.keys = [
+ [
+ ["7", "8", "9", "⌫"],
+ ["4", "5", "6", "+"],
+ ["1", "2", "3", "-"],
+ ["↓", "0", ".", "↓"]
+ ]
+ ]
elif language == "de":
self.keys = [
[
@@ -155,7 +165,7 @@ class Keyboard(Gtk.Box):
self.pallet_nr = p
columns = 0
- if self.purpose_is_digits():
+ if self.purpose in (Gtk.InputPurpose.DIGITS, Gtk.InputPurpose.NUMBER):
for r, row in enumerate(self.keys[p]):
for k, key in enumerate(row):
x = k * 2
@@ -253,6 +263,3 @@ class Keyboard(Gtk.Box):
widget.get_style_context().add_class("active")
else:
widget.get_style_context().remove_class("active")
-
- def purpose_is_digits(self):
- return self.entry.get_input_purpose() == Gtk.InputPurpose.DIGITS
diff --git a/panels/gcode_macros.py b/panels/gcode_macros.py
index 09ca03f7..50f11bf0 100644
--- a/panels/gcode_macros.py
+++ b/panels/gcode_macros.py
@@ -82,20 +82,26 @@ class Panel(ScreenPanel):
pattern = re.compile(r'params\.(?P[a-zA-Z0-9_]+)'
r'(?:\s*\|\s*default\(\s*(?P[^\)]+)\s*\))?'
- r'(?:\s*\|\s*(?P[a-zA-Z]+))?')
+ r'(?:\s*\|\s*(?P[a-zA-Z]+))?')
for line in gcode:
if line.startswith("{") and "params." in line:
result = re.search(pattern, line)
if result:
result = result.groupdict()
default = result.get("default", "")
- hint = result.get("hint", "")
+ type_hint = result.get("type_hint", "")
entry = Gtk.Entry(placeholder_text=default)
- if hint in ("int", "float"):
+ if type_hint == "int":
entry.set_input_purpose(Gtk.InputPurpose.DIGITS)
+ entry.set_input_hints(Gtk.InputHints.NO_EMOJI)
+ entry.get_style_context().add_class("active")
+ elif type_hint == "float":
+ entry.set_input_purpose(Gtk.InputPurpose.NUMBER)
+ entry.set_input_hints(Gtk.InputHints.EMOJI)
entry.get_style_context().add_class("active")
else:
entry.set_input_purpose(Gtk.InputPurpose.ALPHA)
+ entry.set_input_hints(Gtk.InputHints.NONE)
icon = self._gtk.PixbufFromIcon("hashtag")
entry.set_icon_from_pixbuf(Gtk.EntryIconPosition.SECONDARY, icon)
entry.connect("icon-press", self.on_icon_pressed)
@@ -120,12 +126,15 @@ class Panel(ScreenPanel):
entry.grab_focus()
self._screen.remove_keyboard()
if entry.get_input_purpose() == Gtk.InputPurpose.ALPHA:
- entry.set_input_purpose(Gtk.InputPurpose.DIGITS)
+ if entry.get_input_hints() in (Gtk.InputHints.NONE, Gtk.InputHints.EMOJI):
+ entry.set_input_purpose(Gtk.InputPurpose.NUMBER)
+ else:
+ 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)
+ self.show_keyboard(entry, event)
def run_gcode_macro(self, widget, macro):
params = ""