[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25589] trunk/blender/release/scripts/ui/ space_userpref.py: Added 'Add New' buttons to key maps shown in filtered mode.

Matt Ebb matt at mke3.net
Mon Dec 28 10:19:33 CET 2009


Revision: 25589
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25589
Author:   broken
Date:     2009-12-28 10:19:32 +0100 (Mon, 28 Dec 2009)

Log Message:
-----------
Added 'Add New' buttons to key maps shown in filtered mode.

Also on adding new, it expands the key map category and clears the 
filter so you can see the newly added item.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2009-12-28 08:01:19 UTC (rev 25588)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2009-12-28 09:19:32 UTC (rev 25589)
@@ -1476,12 +1476,13 @@
 
         for km in kc.keymaps:
             filtered_items = [kmi for kmi in km.items if filter in kmi.name.lower()]
-
+            
             if len(filtered_items) != 0:
                 km = km.active()
 
+                layout.set_context_pointer("keymap", km)
                 col = layout.column()
-                col.set_context_pointer("keymap", km)
+               
                 row = col.row()
                 row.label(text=km.name, icon="DOT")
 
@@ -1495,6 +1496,12 @@
 
                 for kmi in filtered_items:
                     self.draw_kmi(kc, km, kmi, col, 1)
+                    
+                # "Add New" at end of keymap item list
+                col = self.indented_layout(layout, 1)
+                subcol = col.split(percentage=0.2).column()
+                subcol.active = km.user_defined
+                subcol.operator("wm.keyitem_add", text="Add New", icon='ZOOMIN')
 
     def draw_hierarchy(self, defkc, layout):
         for entry in KM_HIERARCHY:
@@ -1805,10 +1812,19 @@
     def execute(self, context):
         wm = context.manager
         km = context.keymap
+        kc = wm.default_keyconfig
+        
         if km.modal:
             km.add_modal_item("", 'A', 'PRESS') # kmi
         else:
-            km.add_item("", 'A', 'PRESS') # kmi
+            km.add_item("none", 'A', 'PRESS') # kmi
+            
+        # clear filter and expand keymap so we can see the newly added item
+        if kc.filter != '':
+            kc.filter = ''
+            km.items_expanded = True
+            km.children_expanded = True
+        
         return {'FINISHED'}
 
 





More information about the Bf-blender-cvs mailing list