Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

React Native Press Two Buttons at the same time

$
0
0

Goal

I need users to be able to press up to 4 buttons at the same time in React Native.

Current Roadblock

I'm using TouchableHighlight and when one button is pressed, none of the other 3 buttons can be pressed by the user.

Code

This is the function I'm using to display each of the 4 coloured quadrants you see below. If including more code will be helpful, just let me know!

    return (
      <TouchableOpacity
        style={[styles.button, styles[color]]}
        onPress={() => {
          EventRegister.emit('firstPressed', color);
          EventRegister.removeEventListener(this.listener);
          this.setState({[color]: true});
        }}
        disabled={this.state[color]}></TouchableOpacity>
    );
  };

Screenshot

This is a screenshot of the app where once the countdown clock gets to zero, 4 players race to push each button as quickly as they can (it's an iPad app so they have a large playing surface). Each player needs to receive feedback from their touch or they will think they lost because the app didn't recognize their input.

ScreenShot


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>