diff --git a/src/UI_Components/Clickable.re b/src/UI_Components/Clickable.re index 5a8a371f6..f6ec15d55 100644 --- a/src/UI_Components/Clickable.re +++ b/src/UI_Components/Clickable.re @@ -23,9 +23,13 @@ let%component make = ( ~style=[], ~onClick=() => (), + ~onDown=() => (), ~onRightClick=() => (), + ~onRightDown=() => (), ~onDoubleClick=?, + ~onDoubleDown=?, ~onAnyClick=_event => (), + ~onAnyDown=_event => (), ~componentRef=?, ~onBlur=?, ~onFocus=?, @@ -62,9 +66,24 @@ let%component make = isMouseCaptured := false; }; - let onMouseDown = _event => { + let onMouseDown = (mouseEvt: NodeEvents.mouseButtonEventParams) => { capture(); mouseDownTimes := (Time.now(), fst(mouseDownTimes^)); + + if (isMouseCapturedHere^) { + switch (mouseEvt.button) { + | MouseButton.BUTTON_LEFT => + if (onDoubleDown != None && isDoubleClick()) { + Option.get(onDoubleDown, ()); + } else { + onDown(); + } + | MouseButton.BUTTON_RIGHT => onRightDown() + | _ => () + }; + + onAnyDown(mouseEvt); + }; }; let onMouseLeave = _event => { releaseCapture(); diff --git a/src/UI_Components/Clickable.rei b/src/UI_Components/Clickable.rei index a5fff1a9e..f8523626c 100644 --- a/src/UI_Components/Clickable.rei +++ b/src/UI_Components/Clickable.rei @@ -20,9 +20,13 @@ let make: ~key: Brisk_reconciler.Key.t=?, ~style: list(Revery_UI.Style.viewStyleProps)=?, ~onClick: unit => unit=?, + ~onDown: unit => unit=?, ~onRightClick: unit => unit=?, + ~onRightDown: unit => unit=?, ~onDoubleClick: unit => unit=?, + ~onDoubleDown: unit => unit=?, ~onAnyClick: NodeEvents.mouseButtonEventParams => unit=?, + ~onAnyDown: NodeEvents.mouseButtonEventParams => unit=?, ~componentRef: Revery_UI.node => unit=?, ~onBlur: Revery_UI.NodeEvents.focusHandler=?, ~onFocus: Revery_UI.NodeEvents.focusHandler=?,