mirror of
https://github.com/JannisX11/blockbench.git
synced 2025-03-19 17:01:55 +08:00
Fix alt tools not working on unfocused window
This commit is contained in:
parent
af6a3495e1
commit
1dfef36437
@ -335,17 +335,39 @@ onVueSetup(function() {
|
||||
}
|
||||
})
|
||||
|
||||
setInterval(() => {
|
||||
var focus = document.hasFocus();
|
||||
if (Pressing.shift && !focus) Pressing.shift = false;
|
||||
if (Pressing.alt && !focus) {
|
||||
window.addEventListener('blur', event => {
|
||||
if (Pressing.alt) {
|
||||
if (Toolbox.original && Toolbox.original.alt_tool) {
|
||||
Toolbox.original.select()
|
||||
delete Toolbox.original;
|
||||
}
|
||||
Pressing.alt = false;
|
||||
}
|
||||
}, 100)
|
||||
Pressing.shift = false;
|
||||
Pressing.alt = false;
|
||||
Pressing.ctrl = false;
|
||||
})
|
||||
|
||||
window.addEventListener('focus', event => {
|
||||
function click_func(event) {
|
||||
if (event.altKey && Toolbox.selected.alt_tool && !Toolbox.original && !open_interface) {
|
||||
var orig = Toolbox.selected;
|
||||
var alt = BarItems[Toolbox.selected.alt_tool];
|
||||
if (alt && Condition(alt)) {
|
||||
alt.select()
|
||||
Toolbox.original = orig;
|
||||
}
|
||||
}
|
||||
remove_func();
|
||||
}
|
||||
let removed = false
|
||||
function remove_func() {
|
||||
if (removed) return;
|
||||
removed = true;
|
||||
removeEventListeners(window, 'keydown mousedown', click_func, true);
|
||||
}
|
||||
addEventListeners(window, 'keydown mousedown', click_func, true);
|
||||
setTimeout(remove_func, 100);
|
||||
})
|
||||
|
||||
$(document).on('keydown mousedown', function(e) {
|
||||
if (Keybinds.recording || e.which < 4) return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user