stat panel focus reset happens _before_ verb commands are ran (#58196)

This commit is contained in:
William Wallace
2021-04-07 16:37:12 -07:00
committed by GitHub
parent ba570d9625
commit 9cc0b24fc3
+18 -4
View File
@@ -310,6 +310,15 @@ var under_menu = document.querySelector('#under_menu');
var statcontentdiv = document.querySelector('#statcontent');
var storedimages = [];
// Any BYOND commands that could result in the client's focus changing go through this
// to ensure that when we relinquish our focus, we don't do it after the result of
// a command has already taken focus for itself.
function send_byond_focus_command(url) {
setTimeout(function() {
window.location.href = url;
}, 0);
}
function createStatusTab(name) {
if (name.indexOf(".") != -1)
name = name.split(".")[0];
@@ -1018,6 +1027,12 @@ function draw_spells(cat) {
document.getElementById("statcontent").appendChild(table);
}
function make_verb_onclick(command) {
return function() {
send_byond_focus_command("byond://winset?command=" + command);
};
}
function draw_verbs(cat){
statcontentdiv[textContentKey] = "";
var table = document.createElement("div");
@@ -1039,7 +1054,8 @@ function draw_verbs(cat){
}
var a = document.createElement("a");
a.href = "byond://winset?command=" + command.replace(/\s/g, "-");
a.href = "#"
a.onclick = make_verb_onclick(command.replace(/\s/g, "-"));
a.className = "grid-item";
var t = document.createElement("span");
t[textContentKey] = command;
@@ -1091,9 +1107,7 @@ function set_style_sheet(sheet) {
}
function restoreFocus() {
setTimeout(function() {
window.location.href = "byond://winset?map.focus=true";
}, 0);
send_byond_focus_command("byond://winset?map.focus=true")
}
document[addEventListenerKey]("mouseup", restoreFocus);