Skip to content

Commit 033f857

Browse files
jongundmcking65
authored andcommitted
Treeview Examples: Make Right Arrow Move Focus to First Child (Pull #390)
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.
1 parent 1ace662 commit 033f857

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

examples/treeview/treeview-1/js/treeitem.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ Treeitem.prototype.handleKeydown = function (event) {
132132
}
133133

134134
if (event.shift) {
135-
printableCharacter(this);
135+
if (isPrintableCharacter(char)) {
136+
printableCharacter(this);
137+
}
136138
}
137139
else {
138140
switch (event.keyCode) {
@@ -170,9 +172,14 @@ Treeitem.prototype.handleKeydown = function (event) {
170172

171173
case this.keyCode.RIGHT:
172174
if (this.isExpandable) {
173-
this.tree.expandTreeitem(this);
174-
flag = true;
175+
if (this.isExpanded()) {
176+
this.tree.setFocusToNextItem(this);
177+
}
178+
else {
179+
this.tree.expandTreeitem(this);
180+
}
175181
}
182+
flag = true;
176183
break;
177184

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

201208
default:
202-
printableCharacter(this);
209+
if (isPrintableCharacter(char)) {
210+
printableCharacter(this);
211+
}
203212
break;
204213
}
205214

examples/treeview/treeview-2/js/treeitemLinks.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ TreeitemLink.prototype.handleKeydown = function (event) {
143143
this.stopDefaultClick = true;
144144
}
145145
else {
146-
printableCharacter(this);
146+
if (isPrintableCharacter(char)) {
147+
printableCharacter(this);
148+
}
147149
}
148150
}
149151
else {
@@ -177,9 +179,14 @@ TreeitemLink.prototype.handleKeydown = function (event) {
177179

178180
case this.keyCode.RIGHT:
179181
if (this.isExpandable) {
180-
this.tree.expandTreeitem(this);
181-
flag = true;
182+
if (this.isExpanded()) {
183+
this.tree.setFocusToNextItem(this);
184+
}
185+
else {
186+
this.tree.expandTreeitem(this);
187+
}
182188
}
189+
flag = true;
183190
break;
184191

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

208215
default:
209-
printableCharacter(this);
216+
if (isPrintableCharacter(char)) {
217+
printableCharacter(this);
218+
}
210219
break;
211220
}
212221
}

0 commit comments

Comments
 (0)