Changeset 10866

Show
Ignore:
Timestamp:
10/16/07 12:04:22 (10 months ago)
Author:
davidb
Message:

Fixes #4679. Improved key handling.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/layout/AccordionContainer.js

    r10791 r10866  
    119119                }, 
    120120 
     121                adjacent: function(/*Widget*/ w, /*Boolean*/ forward){ 
     122                        var children = this.getChildren(); 
     123                        var index = dojo.indexOf(children, w); 
     124                        // pick next button to focus on 
     125                        index += forward ? 1 : children.length - 1; 
     126                        return children[ index % children.length ]; 
     127                }, 
     128 
    121129                // note: we are treating the container as controller here 
    122                 processKey: function(/*Event*/ evt){ 
    123                         if(this.disabled || evt.altKey || evt.shiftKey || evt.ctrlKey){ 
    124                                 return  dijit.layout.AccordionContainer.superclass._onKeyPress.apply(this, arguments); 
    125                         } 
    126                         var forward = true; 
    127                         switch(evt.keyCode){                             
    128                                 case dojo.keys.LEFT_ARROW: 
    129                                 case dojo.keys.UP_ARROW: 
    130                                         forward = false; 
    131                                         // fallthrough 
    132                                 case dojo.keys.RIGHT_ARROW: 
    133                                 case dojo.keys.DOWN_ARROW: 
    134                                         // find currently focused button in children array 
    135                                         var children = this.getChildren(); 
    136                                         var index = dojo.indexOf(children, evt._dijitWidget); 
    137                                         // pick next button to focus on 
    138                                         index += forward ? 1 : children.length - 1; 
    139                                         var next = children[ index % children.length ]; 
    140                                         dojo.stopEvent(evt); 
    141                                         next._onTitleClick(); 
     130                processKey: function(/*Event*/ e){ 
     131                        if(this.disabled || e.altKey ){ return; } 
     132                        var k = dojo.keys; 
     133                        switch(e.keyCode){ 
     134                                case k.LEFT_ARROW: 
     135                                case k.UP_ARROW: 
     136                                case k.PAGE_UP: 
     137                                        dojo.stopEvent(e); 
     138                                        this.adjacent(e._dijitWidget, false)._onTitleClick(); 
     139                                        break; 
     140                                case k.RIGHT_ARROW: 
     141                                case k.DOWN_ARROW: 
     142                                case k.PAGE_DOWN: 
     143                                        dojo.stopEvent(e); 
     144                                        this.adjacent(e._dijitWidget, true)._onTitleClick(); 
     145                                        break; 
     146                                default: 
     147                                        if (e.ctrlKey && e.keyCode == k.TAB){ 
     148                                                dojo.stopEvent(e); 
     149                                                this.adjacent(e._dijitWidget, !e.shiftKey)._onTitleClick(); 
     150                                        } 
     151                                 
    142152                        } 
    143153                }