1. Rob Lanphier
  2. jsonwidget-python

Commits

Rob Lanphier  committed f87731a

Retain focus highlight while deleting an item

  • Participants
  • Parent commits f9c9e60
  • Branches default

Comments (0)

Files changed (3)

File TODO.txt

View file
 Things to get done before version 0.1
 
 On deck:
-*  Keep item highlighted while deleting
+*  Change "add fields" to "add items" for sequences
 
 Roadmap
 0.1.0:
-*  Change "add fields" to "add items" for sequences
 *  Clean up imports in "jsonedit"
 *  Add alias for editing address books
+*  Graceful error on mismatched schema
 *  Minimal check for urwid and simpleparse (and look for /etc/lsb-release to 
    figure out the right error message)
 *  Improve documentation in __init__.py
 *  Highlight all children when deleting
 *  Preserve key order in json files when saving
 *  Add a schema selection menu
+*  Add support for configuration files (look into ConfigObj)
+*  Only highlight the "Add Field" buttons rather than the whole row
 
 0.2.0:
 *  Update to urwid 0.9.9 mainloop
 **  Ensure that "delete" over "add fields" area doesn't cause crash
 **  Provide alert "foo is a required field"
 *  Rename "delete node" to something less compscinerdy
+*  Keep item highlighted while deleting
 

File jsonwidget/termedit.py

View file
         widget, node = self.listbox.get_focus()
 
         if node.is_deletable():
+            widget.set_selected()
+            widget.update_w()
             def delete_func():
+                widget.set_selected(False)
+                widget.update_w()
                 return editor.handle_delete_node()
+            def cancel_delete():
+                widget.set_selected(False)
+                widget.update_w()
+                editor.cleanup_delete_request()
             msg = "Delete %s? " % node.get_value().get_title()
             self.yes_no_question(msg,
                                  yesfunc=delete_func,
-                                 nofunc=self.cleanup_delete_request,
-                                 cancelfunc=self.cleanup_delete_request)
+                                 nofunc=cancel_delete,
+                                 cancelfunc=cancel_delete)
         else:
             if isinstance(node, FieldAddNode):
                 nodemsg = 'Cannot delete "add field" buttons'

File jsonwidget/treetools.py

View file
     
     def is_selected(self):
         return self.selected
-    
+
+    def set_selected(self, value=True):
+        self.selected = value
+
     def keypress(self, size, key):
         """allow subclasses to intercept keystrokes"""
         w = self.get_w()