Skip to content

Commit

Permalink
Fix Bug 370229 - Command image buttons cannot be used via keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Li committed Feb 1, 2012
1 parent 6522bd4 commit de4766a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bundles/org.eclipse.orion.client.core/web/orion/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,17 @@ define(['require', 'dojo', 'dijit', 'orion/util', 'dijit/Menu', 'dijit/form/Drop
this.callback.call(context.handler, context);
}
});
// onClick events do not register with keyboard for images
dojo.connect(image, "onkeypress", this, function(e) {
if(e.keyCode === dojo.keys.ENTER || e.keyCode === dojo.keys.SPACE) {
// collect parameters in advance if specified
if (this.parameters && context.collectsParameters()) {
context.commandService._collectParameters("tool", context);
} else if (this.callback) {
this.callback.call(context.handler, context);
}
}
});
} else {
context.domNode = link;
dojo.connect(link, "onclick", this, function() {
Expand All @@ -943,13 +954,21 @@ define(['require', 'dojo', 'dijit', 'orion/util', 'dijit/Menu', 'dijit/form/Drop
}
}
if (image) {
// TODO get image in the focus order for accessibility
image.src = this.image;
dojo.addClass(image, 'commandImage');
if (this.imageClass) {
dojo.addClass(image, this.spriteClass);
dojo.addClass(image, this.imageClass);
}
if (dojo.attr(link, "href") === "javascript:void(0)") {
dojo.attr(image, "tabindex", "0");
dojo.attr(image, "role", "button");
dojo.attr(link, "tabindex", "-1");
dojo.removeAttr(link, "role");
dojo.removeAttr(link, "href");
} else {
dojo.attr(link, "role", "link");
}
dojo.place(image, link, "last");
new CommandTooltip({
connectId: [image],
Expand Down

0 comments on commit de4766a

Please sign in to comment.