CommonClient: Fix address pre-selection (#1406)

This commit is contained in:
recklesscoder 2023-01-23 04:59:51 +01:00 committed by GitHub
parent 032bc75070
commit 1a44f5cf1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

10
kvui.py
View File

@ -392,11 +392,13 @@ class GameManager(App):
Clock.schedule_interval(self.update_texts, 1 / 30)
self.container.add_widget(self.grid)
# If the address contains a port, select it; otherwise, select the host.
s = self.server_connect_bar.text
host_start = s.find("@") + 1
ipv6_end = s.find("]", host_start) + 1
port_start = s.find(":", ipv6_end if ipv6_end > 0 else host_start) + 1
self.server_connect_bar.focus = True
self.server_connect_bar.select_text(
self.server_connect_bar.text.find(":") + 1,
len(self.server_connect_bar.text)
)
self.server_connect_bar.select_text(port_start if port_start > 0 else host_start, len(s))
return self.container