1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-21 21:38:06 +01:00

wicd-curses: avoid setting the focus past the end of the list

This commit is contained in:
Tom Van Braeckel
2014-12-20 10:32:35 +01:00
parent 69810a26db
commit 411e12cfe4

View File

@@ -872,7 +872,8 @@ class appGUI():
get_body().set_focus(self.focusloc[1]) get_body().set_focus(self.focusloc[1])
else: else:
if self.wlessLB != self.no_wlan: if self.wlessLB != self.no_wlan:
self.thePile.get_focus().set_focus(self.focusloc[1]) # Set the focus to the last selected item, but never past the length of the list
self.thePile.get_focus().set_focus(min(self.focusloc[1], len(wlessL) - 1))
else: else:
self.thePile.set_focus(self.wiredCB) self.thePile.set_focus(self.wiredCB)
else: else:
@@ -885,7 +886,8 @@ class appGUI():
if self.focusloc[1] is None: if self.focusloc[1] is None:
self.focusloc[1] = 0 self.focusloc[1] = 0
if self.wlessLB != self.no_wlan: if self.wlessLB != self.no_wlan:
self.wlessLB.set_focus(self.focusloc[1]) # Set the focus to the last selected item, but never past the length of the list
self.wlessLB.set_focus(min(self.focusloc[1], len(wlessL) - 1))
self.prev_state = state self.prev_state = state
if not firstrun: if not firstrun: