0

我正在使用反应原生图表套件。如果您向折线图添加调用函数decorator,则可以在单击数据点时向图形添加行为。这是通过将装饰器函数的返回值放入react-native-svg的 G-tag来管理的。

我想在TextInput我的装饰器中添加一个。react-native-svg 上有一个已关闭的github 问题,其中有一些建议可以让我渲染 textInput。我得到了一个调用的 svg 元素rect和我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
    }
4

0 回答 0