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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -