Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting selected text in PlainTextEdit #381

Open
FanGoH opened this issue Sep 10, 2023 · 0 comments
Open

Getting selected text in PlainTextEdit #381

FanGoH opened this issue Sep 10, 2023 · 0 comments

Comments

@FanGoH
Copy link

FanGoH commented Sep 10, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant