Skip to content

multi-touch handlers in android #47

@rgangopadhya

Description

@rgangopadhya

By multi-touch views I mean something like:

<View
    onTouchStart={() => { console.log('pressing left button'); }}
    onTouchEnd={() => { console.log('releasing left button'); }}
>
    {...}
</View>
<View
    onTouchStart={() => { console.log('pressing right button'); }}
    onTouchEnd={() => { console.log('releasing right button'); }}
>
    {...}
</View>

The idea is the user has to hold both the left and right button for something to be triggered (the bit that waits for both to be pressed isn't in the example above, but I want to make clear that the two touchables are separate elements).

This works fine on iOS but not on Android: related to facebook/react-native#10068.

So, was hoping I could use this library to work around that issue. Doesn't seem to work however -- replacing the above with

<BaseButton
  onActiveStateChange={(isActive) => {
    if (isActive) {
      console.log('pressing left button');
    } else {
      console.log('releasing left button');
    }
  }}
>
  {...}
</BaseButton>
<BaseButton
  onActiveStateChange={(isActive) => {
    if (isActive) {
      console.log('pressing right button');
    } else {
      console.log('releasing right button');
    }
  }}
>
  {...}
</BaseButton>

But this results in the same issue as using View: once one button is held, pressing the other triggers the original button's handler (on Android).

Is there any way to use simultaneousHandlers here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions