UI fixes
The keyboard now has proper backspace and special characters
This commit is contained in:
+75
-28
@@ -140,14 +140,14 @@ class NumpadPopup(Popup):
|
||||
"9",
|
||||
"," if is_float else "C",
|
||||
"0",
|
||||
"⌫",
|
||||
"<-",
|
||||
]
|
||||
|
||||
for btn_text in buttons:
|
||||
btn = RoundedButton(
|
||||
text=btn_text,
|
||||
btn_color=[0.15, 0.15, 0.17, 1]
|
||||
if btn_text in ["C", "⌫", ","]
|
||||
if btn_text in ["C", "<-", ","]
|
||||
else [0.0, 0.65, 0.57, 1],
|
||||
)
|
||||
btn.bind(on_release=self.on_key_press)
|
||||
@@ -178,7 +178,7 @@ class NumpadPopup(Popup):
|
||||
|
||||
def on_key_press(self, instance):
|
||||
key = instance.text
|
||||
if key == "⌫":
|
||||
if key == "<-":
|
||||
self.entered_text = self.entered_text[:-1]
|
||||
elif key == "C":
|
||||
self.entered_text = ""
|
||||
@@ -211,6 +211,8 @@ class KeyboardPopup(Popup):
|
||||
self.is_password = is_password
|
||||
self.on_submit = on_submit
|
||||
self.entered_text = ""
|
||||
self.is_shift = False
|
||||
self.is_symbols = False
|
||||
|
||||
content = BoxLayout(orientation="vertical", padding=15, spacing=15)
|
||||
|
||||
@@ -225,29 +227,9 @@ class KeyboardPopup(Popup):
|
||||
self.display.bind(size=self.display.setter("text_size"))
|
||||
content.add_widget(self.display)
|
||||
|
||||
kbd_layout = BoxLayout(orientation="vertical", spacing=5, size_hint_y=0.6)
|
||||
|
||||
rows = [
|
||||
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
||||
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"],
|
||||
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
|
||||
["y", "x", "c", "v", "b", "n", "m", "⌫", "C"],
|
||||
]
|
||||
|
||||
for row in rows:
|
||||
row_box = BoxLayout(orientation="horizontal", spacing=5)
|
||||
for char in row:
|
||||
btn = RoundedButton(
|
||||
text=char,
|
||||
btn_color=[0.15, 0.15, 0.17, 1]
|
||||
if char in ["C", "⌫"]
|
||||
else [0.0, 0.65, 0.57, 1],
|
||||
)
|
||||
btn.bind(on_release=self.on_key_press)
|
||||
row_box.add_widget(btn)
|
||||
kbd_layout.add_widget(row_box)
|
||||
|
||||
content.add_widget(kbd_layout)
|
||||
self.kbd_layout = BoxLayout(orientation="vertical", spacing=5, size_hint_y=0.6)
|
||||
self.build_keyboard()
|
||||
content.add_widget(self.kbd_layout)
|
||||
|
||||
actions = BoxLayout(orientation="horizontal", spacing=10, size_hint_y=0.25)
|
||||
ok_btn = RoundedButton(text="OK", btn_color=[0.0, 0.65, 0.57, 1])
|
||||
@@ -260,7 +242,7 @@ class KeyboardPopup(Popup):
|
||||
super(KeyboardPopup, self).__init__(
|
||||
title=title,
|
||||
content=content,
|
||||
size_hint=(0.95, 0.8),
|
||||
size_hint=(0.95, 0.85),
|
||||
title_align="center",
|
||||
title_size="18sp",
|
||||
background_color=[0.08, 0.08, 0.09, 0.95],
|
||||
@@ -270,12 +252,77 @@ class KeyboardPopup(Popup):
|
||||
ok_btn.bind(on_release=self.submit)
|
||||
cancel_btn.bind(on_release=self.dismiss)
|
||||
|
||||
def build_keyboard(self):
|
||||
self.kbd_layout.clear_widgets()
|
||||
|
||||
if self.is_symbols:
|
||||
rows = [
|
||||
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
||||
["+", "-", "*", "/", "=", "%", "<", ">", "[", "]"],
|
||||
["@", "#", "$", "&", "(", ")", "_", "\"", "'", ";"],
|
||||
["ABC", "?", "!", ",", ".", ":", "\\", "<-", "C"],
|
||||
["Leertaste"]
|
||||
]
|
||||
else:
|
||||
if self.is_shift:
|
||||
rows = [
|
||||
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
||||
["Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P"],
|
||||
["A", "S", "D", "F", "G", "H", "J", "K", "L"],
|
||||
["Shift", "Y", "X", "C", "V", "B", "N", "M", "<-", "C"],
|
||||
["Sym", "Leertaste", "-", "_", "."]
|
||||
]
|
||||
else:
|
||||
rows = [
|
||||
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
|
||||
["q", "w", "e", "r", "t", "z", "u", "i", "o", "p"],
|
||||
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
|
||||
["shift", "y", "x", "c", "v", "b", "n", "m", "<-", "C"],
|
||||
["Sym", "Leertaste", "-", "_", "."]
|
||||
]
|
||||
|
||||
for row in rows:
|
||||
row_box = BoxLayout(orientation="horizontal", spacing=5)
|
||||
for char in row:
|
||||
if char in ["C", "<-", "shift", "Shift", "Sym", "ABC", "Leertaste"]:
|
||||
btn_color = [0.25, 0.25, 0.28, 1]
|
||||
else:
|
||||
btn_color = [0.0, 0.65, 0.57, 1]
|
||||
|
||||
if (char == "shift" or char == "Shift") and self.is_shift:
|
||||
btn_color = [0.0, 0.45, 0.4, 1]
|
||||
elif char == "Sym" and self.is_symbols:
|
||||
btn_color = [0.0, 0.45, 0.4, 1]
|
||||
|
||||
btn = RoundedButton(
|
||||
text=char,
|
||||
btn_color=btn_color,
|
||||
size_hint_x=2.5 if char == "Leertaste" else 1.0
|
||||
)
|
||||
btn.bind(on_release=self.on_key_press)
|
||||
row_box.add_widget(btn)
|
||||
self.kbd_layout.add_widget(row_box)
|
||||
|
||||
def on_key_press(self, instance):
|
||||
key = instance.text
|
||||
if key == "⌫":
|
||||
if key == "<-":
|
||||
self.entered_text = self.entered_text[:-1]
|
||||
elif key == "C":
|
||||
self.entered_text = ""
|
||||
elif key in ["shift", "Shift"]:
|
||||
self.is_shift = not self.is_shift
|
||||
self.build_keyboard()
|
||||
return
|
||||
elif key == "Sym":
|
||||
self.is_symbols = True
|
||||
self.build_keyboard()
|
||||
return
|
||||
elif key == "ABC":
|
||||
self.is_symbols = False
|
||||
self.build_keyboard()
|
||||
return
|
||||
elif key == "Leertaste":
|
||||
self.entered_text += " "
|
||||
else:
|
||||
self.entered_text += key
|
||||
self.update_display()
|
||||
|
||||
Reference in New Issue
Block a user