toggle fullscreen?

This commit is contained in:
botvid johansson 2025-02-08 23:05:46 +01:00
parent 7373f30ddc
commit 2b6080ba7e
2 changed files with 25 additions and 3 deletions

View File

@ -13,8 +13,8 @@
"windows": [
{
"title": "skrivert",
"width": 800,
"height": 600,
"width": 1080,
"height": 720,
"resizable": true,
"fullscreen": false
}

View File

@ -1,6 +1,8 @@
import { goto } from '$app/navigation';
import type { ExpanderType } from "./index.d.ts";
import { getCurrentWindow } from "@tauri-apps/api/window";
let fullscreen = true;
export const defaultExpanders: Map<string, ExpanderType> = new Map();
export const hotkeys: Map<string, any> = new Map();
@ -82,6 +84,26 @@ hotkeys.set("F1", {
}
})
hotkeys.set("F11", {
action: (e) => {
e.preventDefault()
console.log("Toggle fullscreen")
if (fullscreen) {
getCurrentWindow().setFullscreen(false).then(() => {
fullscreen = false
});
} else {
getCurrentWindow().setFullscreen(true).then(() => {
fullscreen = true
});
}
}
})
hotkeys.set("F12", {
action: (e) => {
e.preventDefault()