mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-04 13:30:48 +00:00
Fix double-click event firing when dragging number input fields in Chromium
This commit is contained in:
parent
4344f28909
commit
dc0ae74cab
2 changed files with 16 additions and 5 deletions
|
@ -121,7 +121,10 @@ impl LayoutMessageHandler {
|
|||
};
|
||||
|
||||
(|| {
|
||||
let update_value = value.as_object().expect("ColorInput update was not of type: object");
|
||||
let Some(update_value) = value.as_object() else {
|
||||
warn!("ColorInput update was not of type: object");
|
||||
return Message::NoOp;
|
||||
};
|
||||
|
||||
// None
|
||||
let is_none = update_value.get("none").and_then(|x| x.as_bool());
|
||||
|
@ -154,7 +157,8 @@ impl LayoutMessageHandler {
|
|||
return (color_button.on_update.callback)(color_button);
|
||||
}
|
||||
|
||||
panic!("ColorInput update was not able to be parsed with color data: {color_button:?}");
|
||||
warn!("ColorInput update was not able to be parsed with color data: {color_button:?}");
|
||||
Message::NoOp
|
||||
})()
|
||||
}
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ export const PRESS_REPEAT_DELAY_MS = 400;
|
|||
export const PRESS_REPEAT_INTERVAL_MS = 72;
|
||||
export const PRESS_REPEAT_INTERVAL_RAPID_MS = 10;
|
||||
|
||||
type EventName = keyof HTMLElementEventMap | keyof WindowEventHandlersEventMap | "modifyinputfield";
|
||||
type EventName = keyof HTMLElementEventMap | keyof WindowEventHandlersEventMap | "modifyinputfield" | "pointerlockchange" | "pointerlockerror";
|
||||
type EventListenerTarget = {
|
||||
addEventListener: typeof window.addEventListener;
|
||||
removeEventListener: typeof window.removeEventListener;
|
||||
|
@ -35,6 +35,7 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
|
|||
let viewportPointerInteractionOngoing = false;
|
||||
let textToolInteractiveInputElement = undefined as undefined | HTMLDivElement;
|
||||
let canvasFocused = true;
|
||||
let inPointerLock = false;
|
||||
|
||||
// Event listeners
|
||||
|
||||
|
@ -55,6 +56,8 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
|
|||
{ target: window.document, eventName: "contextmenu", action: (e: MouseEvent) => onContextMenu(e) },
|
||||
{ target: window.document, eventName: "fullscreenchange", action: () => fullscreen.fullscreenModeChanged() },
|
||||
{ target: window.document.body, eventName: "paste", action: (e: ClipboardEvent) => onPaste(e) },
|
||||
{ target: window.document, eventName: "pointerlockchange", action: onPointerLockChange },
|
||||
{ target: window.document, eventName: "pointerlockerror", action: onPointerLockChange },
|
||||
];
|
||||
|
||||
// Event bindings
|
||||
|
@ -209,9 +212,9 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
|
|||
}
|
||||
|
||||
function onPotentialDoubleClick(e: MouseEvent) {
|
||||
if (textToolInteractiveInputElement) return;
|
||||
if (textToolInteractiveInputElement || inPointerLock) return;
|
||||
|
||||
// Allow only double-clicks
|
||||
// Allow only repeated increments of double-clicks (not 1, 3, 5, etc.)
|
||||
if (e.detail % 2 == 1) return;
|
||||
|
||||
// `e.buttons` is always 0 in the `mouseup` event, so we have to convert from `e.button` instead
|
||||
|
@ -226,6 +229,10 @@ export function createInputManager(editor: Editor, dialog: DialogState, portfoli
|
|||
editor.handle.onDoubleClick(e.clientX, e.clientY, buttons, modifiers);
|
||||
}
|
||||
|
||||
function onPointerLockChange() {
|
||||
inPointerLock = Boolean(window.document.pointerLockElement);
|
||||
}
|
||||
|
||||
// Mouse events
|
||||
|
||||
function onWheelScroll(e: WheelEvent) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue