Make window controls fire on pointer down
All checks were successful
Build Windows App / build-windows (push) Successful in 24m1s
All checks were successful
Build Windows App / build-windows (push) Successful in 24m1s
This commit is contained in:
23
src/App.tsx
23
src/App.tsx
@@ -15,7 +15,7 @@ import {
|
|||||||
X
|
X
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
import type { ReactNode } from "react";
|
import type { PointerEvent, ReactNode } from "react";
|
||||||
import packageInfo from "../package.json";
|
import packageInfo from "../package.json";
|
||||||
import { transformEnv } from "./env";
|
import { transformEnv } from "./env";
|
||||||
import type { EnvDefault } from "./env";
|
import type { EnvDefault } from "./env";
|
||||||
@@ -328,6 +328,12 @@ export default function App() {
|
|||||||
setDefaults((current) => current.filter((_, entryIndex) => entryIndex !== index));
|
setDefaults((current) => current.filter((_, entryIndex) => entryIndex !== index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runWindowControl(event: PointerEvent<HTMLButtonElement>, action?: () => void) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
action?.();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="appShell">
|
<main className="appShell">
|
||||||
<section className="titlebar">
|
<section className="titlebar">
|
||||||
@@ -340,10 +346,7 @@ export default function App() {
|
|||||||
<div className="windowControls">
|
<div className="windowControls">
|
||||||
<button
|
<button
|
||||||
aria-label="Minimize"
|
aria-label="Minimize"
|
||||||
onClick={(event) => {
|
onPointerDown={(event) => runWindowControl(event, window.envHelper?.minimizeWindow)}
|
||||||
event.stopPropagation();
|
|
||||||
window.envHelper?.minimizeWindow();
|
|
||||||
}}
|
|
||||||
title="Minimize"
|
title="Minimize"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
@@ -351,10 +354,7 @@ export default function App() {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
aria-label="Maximize"
|
aria-label="Maximize"
|
||||||
onClick={(event) => {
|
onPointerDown={(event) => runWindowControl(event, window.envHelper?.toggleMaximizeWindow)}
|
||||||
event.stopPropagation();
|
|
||||||
window.envHelper?.toggleMaximizeWindow();
|
|
||||||
}}
|
|
||||||
title="Maximize"
|
title="Maximize"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
@@ -363,10 +363,7 @@ export default function App() {
|
|||||||
<button
|
<button
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
className="closeButton"
|
className="closeButton"
|
||||||
onClick={(event) => {
|
onPointerDown={(event) => runWindowControl(event, window.envHelper?.closeWindow)}
|
||||||
event.stopPropagation();
|
|
||||||
window.envHelper?.closeWindow();
|
|
||||||
}}
|
|
||||||
title="Close"
|
title="Close"
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -198,6 +198,11 @@ textarea:focus {
|
|||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.windowControls,
|
||||||
|
.windowControls * {
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
|
}
|
||||||
|
|
||||||
.windowControls button {
|
.windowControls button {
|
||||||
-webkit-app-region: no-drag;
|
-webkit-app-region: no-drag;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
@@ -209,6 +214,10 @@ textarea:focus {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.windowControls svg {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.windowControls button:hover {
|
.windowControls button:hover {
|
||||||
background: var(--surface-subtle);
|
background: var(--surface-subtle);
|
||||||
border-color: var(--border);
|
border-color: var(--border);
|
||||||
|
|||||||
Reference in New Issue
Block a user