@@ -7,6 +7,7 @@ const LabelManager = (function() {
77 // special keys
88 const Key = {
99 delete : 8 ,
10+ tab : 9 ,
1011 enter : 13 ,
1112 escape : 27 ,
1213 left : 37 ,
@@ -33,7 +34,7 @@ const LabelManager = (function() {
3334
3435 function stopEditing ( ) {
3536 if ( activeObject && activeObject . isEditing ) {
36- if ( ! string ) { updateString ( originalString ) ; }
37+ // if (!string) { updateString(originalString); }
3738 activeObject . stopEditing ( ) ;
3839 activeObject = null ;
3940 originalString = string = null ;
@@ -53,6 +54,8 @@ const LabelManager = (function() {
5354 if ( string === null ) { string = originalString ; }
5455 updateString ( string . slice ( 0 , - 1 ) ) ;
5556 break ;
57+ case Key . tab :
58+ break ;
5659 case Key . enter :
5760 stopEditing ( ) ;
5861 break ;
@@ -72,15 +75,19 @@ const LabelManager = (function() {
7275 }
7376 } )
7477 document . addEventListener ( 'keypress' , function ( e ) {
78+ // console.log(String.fromCharCode(e.which), e.which);
7579 if ( activeObject && activeObject . isEditing ) {
76- if ( string === null ) { string = '' ; }
77- updateString ( string + String . fromCharCode ( e . which ) ) ;
80+ if ( e . which === 32 ) {
81+ e . preventDefault ( ) ;
82+ }
83+ if ( ! e . ctrlKey && ! e . metaKey && ! e . altKey ) {
84+ if ( string === null ) { string = '' ; }
85+ updateString ( string + String . fromCharCode ( e . which ) ) ;
86+ }
7887 }
7988 } ) ;
8089
81- document . addEventListener ( 'mousedown' , function ( e ) {
82- stopEditing ( ) ;
83- } ) ;
90+ document . addEventListener ( 'mousedown' , stopEditing ) ;
8491
8592 return LabelManager ;
8693} ) ( ) ;
0 commit comments