From 2b6080ba7e5e091f8f9b3b8e0404c570baac9bf8 Mon Sep 17 00:00:00 2001 From: qwertyist-win Date: Sat, 8 Feb 2025 23:05:46 +0100 Subject: [PATCH] toggle fullscreen? --- src-tauri/tauri.conf.json | 6 +++--- src/modules/keyboard.ts | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c6421c8..e27f56b 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -13,8 +13,8 @@ "windows": [ { "title": "skrivert", - "width": 800, - "height": 600, + "width": 1080, + "height": 720, "resizable": true, "fullscreen": false } @@ -34,4 +34,4 @@ "icons/icon.ico" ] } -} +} \ No newline at end of file diff --git a/src/modules/keyboard.ts b/src/modules/keyboard.ts index af0f502..795cf1e 100644 --- a/src/modules/keyboard.ts +++ b/src/modules/keyboard.ts @@ -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 = new Map(); export const hotkeys: Map = 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()