ソースを参照

add shortcut to focus on Product field and automatically focus on Product field after saving

Daniel Sheffield 3 年 前
コミット
c4eebf3646
1 ファイル変更9 行追加0 行削除
  1. 9 0
      app/activities/TransactionEditor.py

+ 9 - 0
app/activities/TransactionEditor.py

@@ -33,6 +33,9 @@ class TransactionEditor(FocusWidget):
             self.update()
         elif key == 'insert':
             self.save_and_clear_cb()
+            self.focus_on_product()
+        elif key == 'ctrl p':
+            self.focus_on_product()
         else:
             return super().keypress(size, key)
 
@@ -78,6 +81,12 @@ class TransactionEditor(FocusWidget):
         self.organic_checkbox.set_state(True if self.data['organic'] == 'true' else False)
         return self
 
+    def focus_on_product(self):
+        path = self.container.get_focus_path()
+        while path != [2,0,1,0,0]:
+            self.advance_focus()
+            path = self.container.get_focus_path()
+
     def __init__(self,
         query_manager: QueryManager,
         fields: List[str],