Fix the '+ keypress not adding a second tag' bug by adding event listener to Add...
authorAndy Allan <gravitystorm@gmail.com>
Wed, 17 Nov 2010 11:33:46 +0000 (11:33 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 17 Nov 2010 11:33:46 +0000 (11:33 +0000)
TODO.txt
net/systemeD/potlatch2/TagViewer.mxml

index 2132037..e24337b 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -18,7 +18,6 @@ Potlatch 2: main outstanding issues
 == Tag editing ==
 
 * initialiseEditors is quite slow (typically 150ms)
-* Can't use + for second tag
 * Tag panel jumps up and down when number spinner is used on bike parking
 * New relation panel jumps up and down, but I haven't seen it on editing existing relations
 * Changing relation ref doesn't update the main tagviewer until the entity is reselected
index 7dbc6f5..0e65881 100644 (file)
@@ -67,7 +67,7 @@
 
         <mx:HBox horizontalAlign="right" width="100%">
           <mx:LinkButton label="Delete" click="advancedTagGrid.removeTag()" enabled="{advancedTagGrid.selectedItem != null? true : false}"/>
-          <mx:LinkButton label="Add" click="advancedTagGrid.addNewTag()"/>
+          <mx:LinkButton label="Add" click="advancedTagGrid.addNewTag()" id="advancedAddButton"/>
         </mx:HBox>
         
         <mx:DataGrid editable="true" width="100%" height="25%" id="relationsGrid"
              setupAdvanced(selectedEntity);
       }
 
+      /**
+      * When you enter a new tag and press enter, the focus moves to the add button
+      * Adding an event listener to the button and listening for + means that you
+      * can add two consecutive tags with the same keypress. This relies on focus
+      * moving to the "add" button, though, so it's not robust to rearranging the UI.
+      */
+      private function advancedAddButtonKeyboardEvent(event:KeyboardEvent):void {
+          switch (event.keyCode) {
+            case 187:   addNewTag(); break;                          // + - add tag
+          }
+      }
+
       private var listeningToRelations:Array = [];
       
       private function setupAdvanced(entity:Entity):void {
                advancedTagGrid.init(entity);
+        advancedAddButton.addEventListener(KeyboardEvent.KEY_DOWN, advancedAddButtonKeyboardEvent);
 
                if ( entity == null ) {
                        advancedID.htmlText = "";