行情区全屏改为仅 F 键,并强化键盘监听
- 移除 Ctrl+空格,使用 KeyF 与多节点捕获监听 - 点击图表区域聚焦,进入行情页自动聚焦 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -795,13 +795,28 @@
|
||||
tfDigitTimer = setTimeout(commitTfDigitBuffer, TF_DIGIT_TIMEOUT_MS);
|
||||
}
|
||||
|
||||
function isChartFullscreenShortcut(e) {
|
||||
if (e.altKey || e.metaKey) return false;
|
||||
const isSpace =
|
||||
e.code === "Space" || e.key === " " || e.key === "Spacebar";
|
||||
if (isSpace && e.ctrlKey) return true;
|
||||
if ((e.key === "f" || e.key === "F") && !e.ctrlKey && !e.shiftKey) return true;
|
||||
return false;
|
||||
function isChartFullscreenKey(e) {
|
||||
if (e.ctrlKey || e.altKey || e.metaKey || e.shiftKey) return false;
|
||||
return e.code === "KeyF" || e.key === "f" || e.key === "F";
|
||||
}
|
||||
|
||||
function onChartFullscreenKey(e) {
|
||||
if (!isMarketPageActive() || !isChartFullscreenKey(e)) return;
|
||||
if (isTypingInField(e.target)) return;
|
||||
e.preventDefault();
|
||||
e.stopImmediatePropagation();
|
||||
toggleChartFullscreen();
|
||||
}
|
||||
|
||||
function focusMarketChartArea() {
|
||||
const wrap = elChartWrap;
|
||||
if (!wrap) return;
|
||||
if (!wrap.hasAttribute("tabindex")) wrap.setAttribute("tabindex", "-1");
|
||||
try {
|
||||
wrap.focus({ preventScroll: true });
|
||||
} catch (err) {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
function onMarketKeydown(e) {
|
||||
@@ -814,14 +829,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (isChartFullscreenShortcut(e)) {
|
||||
if (isTypingInField(e.target) && (e.key === "f" || e.key === "F")) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
toggleChartFullscreen();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canUseTfKeyboard(e)) return;
|
||||
if (e.key >= "0" && e.key <= "9") {
|
||||
e.preventDefault();
|
||||
@@ -1603,7 +1610,16 @@
|
||||
updateIndicators();
|
||||
});
|
||||
});
|
||||
const pageMarket = document.getElementById("page-market");
|
||||
const fsKeyTargets = [window, pageMarket, elChartWrap, chartHost].filter(Boolean);
|
||||
fsKeyTargets.forEach(function (el) {
|
||||
el.addEventListener("keydown", onChartFullscreenKey, true);
|
||||
});
|
||||
window.addEventListener("keydown", onMarketKeydown, true);
|
||||
if (elChartWrap) {
|
||||
if (!elChartWrap.hasAttribute("tabindex")) elChartWrap.setAttribute("tabindex", "-1");
|
||||
elChartWrap.addEventListener("mousedown", focusMarketChartArea);
|
||||
}
|
||||
if (elFsExchange) {
|
||||
elFsExchange.addEventListener("change", function () {
|
||||
syncMainFromFsToolbar();
|
||||
@@ -1643,6 +1659,7 @@
|
||||
} else {
|
||||
readQuery();
|
||||
}
|
||||
focusMarketChartArea();
|
||||
startAutoRefresh();
|
||||
await loadChart(false);
|
||||
startPriceTagTimer();
|
||||
|
||||
Reference in New Issue
Block a user