nodegui/react-nodegui

Getting selected text in PlainTextEdit

FanGoH opened this issue · 0 comments

I am trying to get the selected text from a PlainTextEdit component

The snippet that I though of was

export const TextPart = () => {
  const textViewRef = createRef<QPlainTextEdit>(null);

  useEffect(() => {
    textViewRef.current.addEventListener("selectionChanged", () => {
      // How I should retrieve the selected text?
      textViewRef.current?.setPlainText("Hello World!");
    });

    return () => textViewRef.current.removeEventListener("selectionChanged");
  }, [textViewRef.current]);

  return (
    <View style="margin: 30px;">
      <Text>This is the cool part</Text>
      <PlainTextEdit ref={textViewRef} />
    </View>
  );
};

Which I though could help, but I don't think that the ref is giving me access to a @nodegui element.

How I could access the QPlainTextEdit element? Or how does the react wrapping works?