Drive keys (canvas GridKeys): a screen key's "key" in the profile clicks it (F1 F2 F3 / F5 − + 3 F T N; "keypad" K1–K8 / E3 kept for the keypad), the menus' own buttons too (1 2 3 the scopes / presets, H hide all / all off); in an open menu ↑ ↓ move the row (the keypad's encoder will send the same arrows), Enter its first button, Space its eye, + adds it, ⌫ up a folder, Esc closes. The key in each button's corner and the row in purple with ⏎ ␣ +, from the first key pressed on (a touch-only screen stays clean)
CI / check (push) Successful in 23s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-12-03 12:27:45 +01:00
1 parent d39e3b5edd
commit 1ee79fff66
6 files changed
+128 -18

No files matched your search

+13 -6
View File
@@ -30,6 +30,13 @@ export function cellButton(cls, html, title, action) {
return el;
}
// A hardware key for a button: pressed, it clicks it; its label in the corner (driving.js, the keys)
export function bindKey(el, key) {
el.dataset.key = key;
el.dataset.label = key === "-" ? "−" : key.length === 1 ? key.toUpperCase() : key;
return el;
}
export const emptyRow = (text) => Object.assign(document.createElement("p"), { className: "drive-panel__empty", textContent: text });
function panel(cls, label, inner) {
@@ -56,7 +63,7 @@ export function pointsMenu(ctx) {
<div class="drive-points__bar"></div>
<div class="drive-panel__list drive-points__list"></div>
<div class="drive-panel__foot"></div>
<button type="button" class="drive-panel__wide" data-action="hide-all">Hide all</button>`);
<button type="button" class="drive-panel__wide" data-action="hide-all" data-key="h" data-label="H">Hide all</button>`);
const input = el.querySelector("input");
const bar = el.querySelector(".drive-points__bar");
const list = el.querySelector(".drive-points__list");
@@ -189,8 +196,8 @@ export function pointsMenu(ctx) {
el.querySelector(".drive-panel__note").textContent = "folders";
renderFolder();
} else {
bar.replaceChildren(...[["near", "Near the car"], ["ahead", "Ahead"], ["shown", "Shown"]].map(([id, label]) => {
const chip = cellButton("scope", label, label, () => { scope = id; render(); });
bar.replaceChildren(...[["near", "Near the car"], ["ahead", "Ahead"], ["shown", "Shown"]].map(([id, label], i) => {
const chip = bindKey(cellButton("scope", label, label, () => { scope = id; render(); }), String(i + 1));
chip.setAttribute("aria-pressed", String(scope === id));
return chip;
}), cellButton("mode", `<span class="drive-key__icon">▣</span><span class="drive-key__label">Folders</span>`, "Folders", () => { scope = "folder"; input.value = ""; render(); }));
@@ -223,7 +230,7 @@ export function layersMenu(ctx) {
<div class="drive-layers__source"></div>
<div class="drive-panel__list drive-layers__list"></div>
<div class="drive-panel__foot"></div>
<button type="button" class="drive-panel__wide" data-action="all-off">All off</button>`);
<button type="button" class="drive-panel__wide" data-action="all-off" data-key="h" data-label="H">All off</button>`);
const list = el.querySelector(".drive-layers__list");
let order = [];
let keeping = false;
@@ -251,7 +258,7 @@ export function layersMenu(ctx) {
if (el.hidden) return;
const presets = loadPresets();
const current = presetOn(presets);
el.querySelector(".drive-layers__presets").replaceChildren(...PRESETS.map(([id, icon, label]) => {
el.querySelector(".drive-layers__presets").replaceChildren(...PRESETS.map(([id, icon, label], i) => {
const b = cellButton("preset", `<span class="drive-key__icon">${icon}</span><span class="drive-key__label">${keeping ? `Save as ${label}` : label}</span>`, label, () => {
if (keeping) {
presets[id] = layers().filter((l) => l.toggle.checked).map((l) => l.name);
@@ -263,7 +270,7 @@ export function layersMenu(ctx) {
render();
});
b.setAttribute("aria-pressed", String(!keeping && current === id));
return b;
return bindKey(b, String(i + 1));
}), (() => {
const keep = cellButton("mode", `<span class="drive-key__icon">${keeping ? "✕" : "+"}</span><span class="drive-key__label">${keeping ? "Cancel" : "Keep"}</span>`,
keeping ? "Cancel" : "Keep what is on as a preset", () => { keeping = !keeping; render(); });