简体   繁体   English

将 Touch 事件分配给按钮 React Native Skia

[英]Assign Touch event to buttons React Native Skia

Want to assign touch event to individual button (React native skia) Current code is想要将触摸事件分配给单个按钮(React native skia)当前代码是

    <>
  <Canvas style={{ flex: 1 }}>
    <Fill color="#f2f2f2" />
    <OutborderButton x={45} y={150} svg={svg1} ix={33} iy={138} shade={shade} ></OutborderButton>
    <OutborderButton x={120} y={150} svg={svg2} ix={108} iy={138} shade={shade}></OutborderButton>
    <OutborderButton x={203} y={150} svg={svg3} ix={197} iy={140} shade={shade}></OutborderButton>
    <OutborderButton x={280} y={150} svg={svg4} ix={268} iy={138} shade={shade}></OutborderButton>
  </Canvas>
</>

and output buttons looks like these和输出按钮看起来像这些

enter image description here在此处输入图像描述

You could overlay a Pressable or TouchableOpacity over your canvas and control it from there.您可以在画布上覆盖PressableTouchableOpacity并从那里控制它。 Alternatively, you can split the canvas and wrap the elements with pressables.或者,您可以拆分画布并用可按下的元素包裹元素。

There is a discussion about this here这里有关于这个的讨论

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM