Hello, i'm trying to repliacate a piano keyboard l...
# compose
p
Hello, i'm trying to repliacate a piano keyboard like control. Where you can trigger a "touch" by either tap or drag (from other composable/key). I'm having problems to mix those 2 as a drag will only inform the callback of the original composable that captured it. (So if you swipe only one key will be "touched") Is there some alternative? ideally i would love to have an onTouch modifier for every composable but i've been thinking about hoisting all this to an uper layer and detect touches outside of every key, but then i need every child composable reporting sizes and positions wich also haves its problems... Any insight here? I'm aware of PointerInteropFilter but it's not available on CMP.
z
I would probably do the whole keyboard as one composable, since it’s essentially one complex control and you’re not gonna have individual keys as components elsewhere. It’s probably cheaper than having a bunch of little composables too. But if you don’t want to do that, you could still have a single input handler for the whole keyboard and have each key’s input handler forward events to the keyboard one.
p
If the whole keyboard is the one getting all the inputs should the keyboard forward the events to each key? Im concerned here about handling positions of all the keys...
z
Other way around: each key forwards to the keyboard and the keyboard does hit testing itself. There’s no way to forward an input event to another component’s pointerInput so I think if you want a single drag to trigger multiple keys you’d have to hit testing yourself anyway.