better logic for handling lr arrows

pull/2566/head
John McLear 2015-03-25 15:19:52 +00:00
parent c6cac53dda
commit 0c902ced73
1 changed files with 9 additions and 16 deletions

View File

@ -304,34 +304,27 @@ var padeditbar = (function()
}
};
var editbarPosition = 0;
function editbarKeyEvent(evt){
// On arrow keys go to next/previous button item in editbar
if(evt.keyCode !== 39 && evt.keyCode !== 37) return;
// Get our current Focus (Which editbar icon we're currently on)
var currentFocus = $(':focus');
// Get all the focusable items in the editbar
var focusItems = $('#editbar').find('button, select');
// On left arrow move to next button in editbar
if(evt.keyCode === 37){
var nextFocus = $(currentFocus).parent().parent().prev();
// No button in this focus so move on
if(nextFocus.find("button").length === 0){
$(nextFocus).prev().find("button").focus();
}else{
$(currentFocus).parent().parent().prev().find("button").focus();
}
editbarPosition--;
$(focusItems[editbarPosition]).focus();
}
// On right arrow move to next button in editbar
if(evt.keyCode === 39){
var nextFocus = $(currentFocus).parent().parent().next();
// No button in this focus so move on
if(nextFocus.find("button").length === 0){
$(nextFocus).next().find("button").focus();
}else{
$(currentFocus).parent().parent().next().find("button").focus();
}
editbarPosition++;
$(focusItems[editbarPosition]).focus();
}
}
function aceAttributeCommand(cmd, ace) {