Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
bugfix: allow selecting blank on remove interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Boneill3 committed Apr 19, 2021
1 parent f22f24e commit 2735165
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions canopen_monitor/ui/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,30 @@ def get_value(self) -> str:


class SelectionPopup(PopupWindow):
def __init__(self: InputPopup,
"""
Input form creates a popup window for selecting
from a list of options
:param parent: parent ui element
:type: any
:param header: header text of popup window
:type: str
:param footer: footer text of popup window
:type: str
:param style: style of window
:type: any
"""
def __init__(self: SelectionPopup,
parent: any,
header: str = 'Alert',
footer: str = 'ESC: close',
style: any = None,
):
content = [" " * 40]
super().__init__(parent, header, content, footer, style)
self.cursor_loc = 0 # TODO: Use scroll instead?
self.cursor_loc = 0

def read_input(self, keyboard_input: int) -> None:
def read_input(self: SelectionPopup, keyboard_input: int) -> None:
"""
Read process keyboard input (ascii or backspace)
Expand All @@ -204,7 +217,7 @@ def read_input(self, keyboard_input: int) -> None:
if keyboard_input == curses.KEY_UP and self.cursor_loc > 0:
self.cursor_loc -= 1
elif keyboard_input == curses.KEY_DOWN and self.cursor_loc < len(
self.content):
self.content) - 1:
self.cursor_loc += 1

def __draw_header(self: SelectionPopup) -> None:
Expand Down Expand Up @@ -251,4 +264,7 @@ def toggle(self: InputPopup) -> bool:
return super().toggle()

def get_value(self):
if self.cursor_loc >= len(self.content):
return ""

return self.content[self.cursor_loc]

0 comments on commit 2735165

Please sign in to comment.