Skip to content

Commit

Permalink
Treeview Examples: Make Right Arrow Move Focus to First Child (Pull #390
Browse files Browse the repository at this point in the history
)

For issue #385, changed right arrow behavior so that when focus is on an expanded parent node, pressing right arrow moves focus to the first child of that parent.
  • Loading branch information
jongund authored and mcking65 committed Apr 30, 2017
1 parent 1ace662 commit 033f857
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
17 changes: 13 additions & 4 deletions examples/treeview/treeview-1/js/treeitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ Treeitem.prototype.handleKeydown = function (event) {
}

if (event.shift) {
printableCharacter(this);
if (isPrintableCharacter(char)) {
printableCharacter(this);
}
}
else {
switch (event.keyCode) {
Expand Down Expand Up @@ -170,9 +172,14 @@ Treeitem.prototype.handleKeydown = function (event) {

case this.keyCode.RIGHT:
if (this.isExpandable) {
this.tree.expandTreeitem(this);
flag = true;
if (this.isExpanded()) {
this.tree.setFocusToNextItem(this);
}
else {
this.tree.expandTreeitem(this);
}
}
flag = true;
break;

case this.keyCode.LEFT:
Expand All @@ -199,7 +206,9 @@ Treeitem.prototype.handleKeydown = function (event) {
break;

default:
printableCharacter(this);
if (isPrintableCharacter(char)) {
printableCharacter(this);
}
break;
}

Expand Down
17 changes: 13 additions & 4 deletions examples/treeview/treeview-2/js/treeitemLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ TreeitemLink.prototype.handleKeydown = function (event) {
this.stopDefaultClick = true;
}
else {
printableCharacter(this);
if (isPrintableCharacter(char)) {
printableCharacter(this);
}
}
}
else {
Expand Down Expand Up @@ -177,9 +179,14 @@ TreeitemLink.prototype.handleKeydown = function (event) {

case this.keyCode.RIGHT:
if (this.isExpandable) {
this.tree.expandTreeitem(this);
flag = true;
if (this.isExpanded()) {
this.tree.setFocusToNextItem(this);
}
else {
this.tree.expandTreeitem(this);
}
}
flag = true;
break;

case this.keyCode.LEFT:
Expand All @@ -206,7 +213,9 @@ TreeitemLink.prototype.handleKeydown = function (event) {
break;

default:
printableCharacter(this);
if (isPrintableCharacter(char)) {
printableCharacter(this);
}
break;
}
}
Expand Down

0 comments on commit 033f857

Please sign in to comment.