react-nodegui icon indicating copy to clipboard operation
react-nodegui copied to clipboard

Getting selected text in PlainTextEdit

Open FanGoH opened this issue 2 years ago • 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?

FanGoH avatar Sep 10 '23 02:09 FanGoH