Skip to content

Getting selected text in PlainTextEdit #381

Description

@FanGoH

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions