mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-02 13:28:11 +08:00
Prevent tooltips from showing when mouse leaves the window over a widget with a tooltip (#3627)
* Fix tooltip visbility issue * Reorganize * Fix --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
co-authored by
Keavon Chambers
parent
df0c9dcba2
commit
97c86125f6
@@ -55,6 +55,16 @@ export function createTooltipState(editor: Editor) {
|
|||||||
}, SHOW_TOOLTIP_DELAY_MS);
|
}, SHOW_TOOLTIP_DELAY_MS);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide tooltip and cancel any pending timeout when the mouse leaves the application window
|
||||||
|
document.addEventListener("mouseleave", () => {
|
||||||
|
if (tooltipTimeout) clearTimeout(tooltipTimeout);
|
||||||
|
closeTooltip();
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("mousedown", closeTooltip);
|
||||||
|
document.addEventListener("keydown", closeTooltip);
|
||||||
|
document.addEventListener("wheel", closeTooltip);
|
||||||
|
|
||||||
editor.subscriptions.subscribeJsMessage(SendShortcutShiftClick, async (data) => {
|
editor.subscriptions.subscribeJsMessage(SendShortcutShiftClick, async (data) => {
|
||||||
update((state) => {
|
update((state) => {
|
||||||
state.shiftClickShortcut = data.shortcut;
|
state.shiftClickShortcut = data.shortcut;
|
||||||
@@ -74,9 +84,6 @@ export function createTooltipState(editor: Editor) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("mousedown", closeTooltip);
|
|
||||||
document.addEventListener("keydown", closeTooltip);
|
|
||||||
|
|
||||||
// Stop showing a tooltip if the user clicks or presses a key, and require the user to first move out of the element before it can re-appear
|
// Stop showing a tooltip if the user clicks or presses a key, and require the user to first move out of the element before it can re-appear
|
||||||
function closeTooltip() {
|
function closeTooltip() {
|
||||||
update((state) => {
|
update((state) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user