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