Hello! Is it possible to configure clicks (better ...
# compose-desktop
p
Hello! Is it possible to configure clicks (better globaly) such that [press -> small amount of pixels move -> up] still be treated as click? Now even there was move for few pixels it is treated as drag and buttons not fired click event. Got bad user experiance - need to make additional effort for keep pointer not moved while clicking.
a
Yes, it’s called touchSlop
🙏 1
p
@Alexander Maryanovsky @Igor Demin In desktop sources foundation-desktop-1.6.10-rc01.jar!/androidx/compose/foundation/gestures/DragGestureDetectorKt.class there is
Copy code
internal fun ViewConfiguration.pointerSlop(pointerType: PointerType): Float {
    return when (pointerType) {
        PointerType.Mouse -> touchSlop * mouseToTouchSlopRatio
        else -> touchSlop
    }
}
where mouseToTouchSlopRatio = 0.125.dp / 18.dp Why is there such need for calculation (why not just use provided touchSlop from Local) and only for mouse pointer type case? With current logic even small move is treated as drag. So I need to multiply original touchSlop for 144 in my own Local ViewConfiguration::touchSlop (LocalViewConfiguration provides ...) to "fix" this behavior, but in this case my redefined touchSlop will be much greater in case of non mouse pointer type.
i
There is no support of redefining "mouseSlop" in the current API. The hardcoded
mouseToTouchSlopRatio
is implementation details, at was introduced as a shortcut for proper mouse support. You can rely on it, but be wary of future changes (they are unlikely though). To properly support redefining, API should be extended. Create an issue for it, if it is important.
Alternatively, don't use built in
drag
if you need a custom behavior. The current default behavior for mouse was chosen by looking at the native OS behavior - the "usual" drag happens almost instantly in most cases.