From f16d9b2bf1fa0c612324ddb76d9728e79212414e Mon Sep 17 00:00:00 2001 From: "xan.lol" Date: Wed, 29 Apr 2026 14:39:29 -0700 Subject: [PATCH] feat: right click for long-press button actions --- src/components/Button.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index f69b1b7bc..ce9b940fc 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -235,6 +235,17 @@ export const Button = forwardRef( const onPointerLeave = useCallback(() => { clearLongPressTimer() }, [clearLongPressTimer]) + const onContextMenu = useCallback( + (e: Event) => { + if (!onLongPressOuter || !IS_WEB || IS_WEB_TOUCH_DEVICE) return + + e.preventDefault() + clearLongPressTimer() + longPressTriggeredRef.current = true + onLongPressOuter(e as unknown as GestureResponderEvent) + }, + [clearLongPressTimer, onLongPressOuter], + ) const onHoverIn = useCallback( (e: MouseEvent) => { setState(s => ({ @@ -604,7 +615,7 @@ export const Button = forwardRef( onPointerDown, onPointerUp, onPointerLeave, - onContextMenu: (e: Event) => e.preventDefault(), + onContextMenu, } : {}) as any)} // @ts-ignore - this will always be a pressable @@ -630,7 +641,9 @@ export const Button = forwardRef( onPressIn={onPressIn} onPressOut={onPressOut} onPress={onPress} - onLongPress={!IS_WEB || IS_WEB_TOUCH_DEVICE ? onLongPressOuter : undefined} + onLongPress={ + !IS_WEB || IS_WEB_TOUCH_DEVICE ? onLongPressOuter : undefined + } onHoverIn={onHoverIn} onHoverOut={onHoverOut} onFocus={onFocus} -- 2.51.2