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": [ "windows": [
{ {
"title": "skrivert", "title": "skrivert",
"width": 800, "width": 1080,
"height": 600, "height": 720,
"resizable": true, "resizable": true,
"fullscreen": false "fullscreen": false
} }
@ -34,4 +34,4 @@
"icons/icon.ico" "icons/icon.ico"
] ]
} }
} }

View File

@ -1,6 +1,8 @@
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import type { ExpanderType } from "./index.d.ts"; 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 defaultExpanders: Map<string, ExpanderType> = new Map();
export const hotkeys: Map<string, any> = 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", { hotkeys.set("F12", {
action: (e) => { action: (e) => {
e.preventDefault() e.preventDefault()