From 27bf542e730f0c0d81bc94e30188f2e83c7de3f2 Mon Sep 17 00:00:00 2001 From: deanlee Date: Thu, 22 May 2025 02:00:09 +0800 Subject: [PATCH] =?UTF-8?q?use=20=E2=80=A2=20for=20password=20masking?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/ui/lib/inputbox.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/ui/lib/inputbox.py b/system/ui/lib/inputbox.py index b164fa4f2abf8c..87e0e92d51b848 100644 --- a/system/ui/lib/inputbox.py +++ b/system/ui/lib/inputbox.py @@ -2,6 +2,9 @@ from openpilot.system.ui.lib.application import gui_app +PASSWORD_MASK_CHAR = "•" + + class InputBox: def __init__(self, max_text_size=255, password_mode=False): self._max_text_size = max_text_size @@ -49,7 +52,7 @@ def _update_text_offset(self): return font = gui_app.font() - display_text = "*" * len(self._input_text) if self._password_mode else self._input_text + display_text = PASSWORD_MASK_CHAR * len(self._input_text) if self._password_mode else self._input_text padding = 10 if self._cursor_position > 0: @@ -111,7 +114,7 @@ def render(self, rect, color=rl.BLACK, border_color=rl.DARKGRAY, text_color=rl.W # Display text font = gui_app.font() - display_text = "*" * len(self._input_text) if self._password_mode else self._input_text + display_text = PASSWORD_MASK_CHAR * len(self._input_text) if self._password_mode else self._input_text padding = 10 # Clip text within input box bounds @@ -148,7 +151,7 @@ def _handle_mouse_input(self, rect, font_size): # Calculate cursor position from click if len(self._input_text) > 0: font = gui_app.font() - display_text = "*" * len(self._input_text) if self._password_mode else self._input_text + display_text = PASSWORD_MASK_CHAR * len(self._input_text) if self._password_mode else self._input_text # Find the closest character position to the click relative_x = mouse_pos.x - (rect.x + 10) + self._text_offset