如何解决react-native-chart-kit 装饰器中的可点击 TextInput
我正在使用 React Native 图表工具包。如果您将名为 decorator
的函数添加到您的折线图中,您可以添加 behavior to your graph when clicking the datapoints。这是通过放置来自 react-native-svg 的装饰器函数 into a G-tag 的返回值来管理的。
我想在我的装饰器中添加一个 TextInput
。 react-native-svg 上有一个封闭的 github issue 有一些建议让我呈现 textInput。我有一个名为 rect
的 svg 元素和我的 TextInput
进行渲染,我也可以使用 autoFocus 将文本输入到 TextInput
中,但它不可点击。
如何使装饰器 TextInput 可点击?
我的装饰器看起来像这样:
() => {
if (tooltipPos.visible) {
return (
<>
<Svg
height="50%"
width="50%"
viewBox={`0 0 300 300`} >
<Rect
x={tooltipPos.x + 180}
y={tooltipPos.y + 50}
width="70"
height="70"
fill="red"
stroke="red"
/>
<TextInput
x={tooltipPos.x - 15}
y={tooltipPos.y + 15}
style={{
backgroundColor: "white",top: tooltipPos.y + 40,left: tooltipPos.x,position: "absolute",elevation: 1,}}
placeholderTextColor="red"
placeholder={tooltipPos.value.toString()}
textAlign={"center"}
onChangeText={(text) => setDecoratorText(text)}
value={decoratorText}
autoFocus={true}
selectTextOnFocus={true}
clearTextOnFocus={true}
/>
</Svg>
</>
)
} else {
return null
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。