A method that handles input for the menu.
Parameters:
Returns:
-
UserResponse | None
–
The selected response or None to continue.
Source code in dev_tool/launcher/menu.py
| def handle_input(self, key: str) -> UserResponse | None:
"""
A method that handles input for the menu.
:param key: The key name.
:return: The selected response or None to continue.
"""
if key == Key.UP:
self.index = (self.index - 1) % len(self.options)
return None
if key == Key.DOWN:
self.index = (self.index + 1) % len(self.options)
return None
if key in (Key.ENTER, Key.LINE_FEED, Key.CARRIAGE_RETURN):
_, response = self.options[self.index]
return response
if key.lower() == Key.QUIT:
return UserResponse.QUIT
return None
|