javascript - React Native - catch all touch events but Touchable's are not bubbling -
i've made tooltip , want close on touch event outside tooltip. don't want make opaque view because still want touch work on whatever pressed.
i tried wrapping app in touchablewithoutfeedback
:
<touchablewithoutfeedback onpress={(e) => this.onapptouch(e)}>
this works if element pressed isn't touchable
, otherwise event seems swallowed , not bubble top level onpress
.
is there way work or else alternative? thanks.
edit: seems limitation of touchables (they swallow gestures) - https://github.com/facebook/react-native/issues/6796
if render tooltip components after touchable background component touchablehighlight preserve touchable tooltip characteristic because of rendering order of components.
so have:
|tooltip1| |tooltip2| |background touchable|
if want hide or shown depending on state:
var touchon = (<touchablehighlight>background component</touchablehighlight>) var touchoff = <your other component/>
and control state , render 1 or other write condition:
{this.state.opentooltip ? touchon : touchoff}
Comments
Post a Comment