8000 system/ui: use • for password masking in InputBox by deanlee · Pull Request #35313 · commaai/openpilot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

system/ui: use • for password masking in InputBox #35313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
8000
Diff view
9 changes: 6 additions & 3 deletions system/ui/lib/inputbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
0