mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-29 19:05:05 +08:00
prevent defaults for alt only if mouse inside image
This commit is contained in:
parent
6f51e05553
commit
79514e5b8e
@ -839,6 +839,31 @@ onUiLoaded(async() => {
|
||||
document.addEventListener("keydown", handleMoveKeyDown);
|
||||
document.addEventListener("keyup", handleMoveKeyUp);
|
||||
|
||||
// Prevent firefox to open toolbar on pressing alt
|
||||
if (hotkeysConfig.canvas_hotkey_zoom === "Alt") {
|
||||
let isAltPressed = false;
|
||||
|
||||
function handleAltKeyDown(e) {
|
||||
if (!activeElement) return;
|
||||
if (e.code === "AltLeft" || e.code === "AltRight") {
|
||||
isAltPressed = true;
|
||||
} else {
|
||||
isAltPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleAltKeyUp(e) {
|
||||
if (isAltPressed) {
|
||||
e.preventDefault();
|
||||
}
|
||||
isAltPressed = false;
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", handleAltKeyDown);
|
||||
document.addEventListener("keyup", handleAltKeyUp);
|
||||
}
|
||||
|
||||
|
||||
// Detect zoom level and update the pan speed.
|
||||
function updatePanPosition(movementX, movementY) {
|
||||
let panSpeed = 2;
|
||||
@ -966,26 +991,3 @@ onUiLoaded(async() => {
|
||||
// Add integration with Inpaint Anything
|
||||
// applyZoomAndPanIntegration("None", ["#ia_sam_image", "#ia_sel_mask"]);
|
||||
});
|
||||
|
||||
|
||||
onUiLoaded(function() {
|
||||
let isAltPressed = false;
|
||||
|
||||
function handleAltKeyDown(e) {
|
||||
if (e.code === "AltLeft" || e.code === "AltRight") {
|
||||
isAltPressed = true;
|
||||
} else {
|
||||
isAltPressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
function handleAltKeyUp(e) {
|
||||
if (isAltPressed) {
|
||||
e.preventDefault();
|
||||
}
|
||||
isAltPressed = false;
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", handleAltKeyDown);
|
||||
document.addEventListener("keyup", handleAltKeyUp);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user