make Alt C and Alt F9 and Escape work from anywhere

This commit is contained in:
John McLear 2015-03-31 13:45:11 +01:00
parent a82e692bdd
commit 35948989b3
3 changed files with 17 additions and 4 deletions

View file

@ -4960,6 +4960,7 @@ function Ace2Inner(){
function focus()
{
top.console.log("window.focus there is a bug with me in FF");
window.focus();
}

View file

@ -225,6 +225,16 @@ var chat = (function()
}
});
$('body:not(#chatinput)').on("keydown", function(evt){
if (evt.altKey && evt.which == 67){
// Alt c focuses on the Chat window
$(this).blur();
parent.parent.chat.show();
parent.parent.chat.focus();
evt.preventDefault();
}
});
$("#chatinput").keypress(function(evt){
//if the user typed enter, fire the send
if(evt.which == 13 || evt.which == 10)

View file

@ -156,8 +156,8 @@ var padeditbar = (function()
});
});
$('#editbar, .popup').on("keydown", function(evt){
editbarKeyEvent(evt);
$('body:not(#editorcontainerbox)').on("keydown", function(evt){
bodyKeyEvent(evt);
});
$('#editbar').show();
@ -307,10 +307,10 @@ var padeditbar = (function()
var editbarPosition = 0;
function editbarKeyEvent(evt){
function bodyKeyEvent(evt){
// If the event is Alt F9 or Escape & we're already in the editbar menu
// Send the users focus back to the pad
if(evt.keyCode === 120 || evt.keyCode === 27){
if((evt.keyCode === 120 && evt.altKey) || evt.keyCode === 27){
// If we're in the editbar already..
// Close any dropdowns we have open..
padeditbar.toggleDropDown("none");
@ -318,6 +318,8 @@ var padeditbar = (function()
// Shift focus away from any drop downs
$(':focus').blur(); // required to do not try to remove!
padeditor.ace.focus(); // Sends focus back to pad
// The above focus doesn't always work in FF, you have to hit enter afterwards
// This still needs fixing cake
}
// On arrow keys go to next/previous button item in editbar