Browse Source

Return no selection if the user aborted selection

Also expose success state
Sebastian Lohff 1 year ago
parent
commit
0517b4d996
1 changed files with 10 additions and 3 deletions
  1. 10
    3
      clintermission/climenu.py

+ 10
- 3
clintermission/climenu.py View File

@@ -105,13 +105,20 @@ class CliMenu:
105 105
         self._items.append(CliMenuOption(text, self._item_num, item=item))
106 106
         self._item_num += 1
107 107
 
108
-    def get_selection(self):
108
+    @property
109
+    def success(self):
109 110
         if not self._ran:
110 111
             self._run()
111 112
 
112
-        item = self._items[self._pos]
113
+        return self._success
113 114
 
114
-        return (item.num, item.item)
115
+    def get_selection(self):
116
+        if self.success:
117
+            item = self._items[self._pos]
118
+
119
+            return (item.num, item.item)
120
+        else:
121
+            return (None, None)
115 122
 
116 123
     def get_selection_num(self):
117 124
         return self.get_selection()[0]

Loading…
Cancel
Save