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

shared keyboard in react #10

Open
hobo1618 opened this issue Oct 31, 2022 · 2 comments
Open

shared keyboard in react #10

hobo1618 opened this issue Oct 31, 2022 · 2 comments

Comments

@hobo1618
Copy link

Hey Arnog,

I'm trying to create a shared virtual keyboard in react, but not sure how to go about it. The docs on cortex say this:

To use a shared virtual keyboard, call the makeSharedVirtualKeyboard() function in the context of the main document.

You should make that call as early as possible, before changing the options of any mathfield or adding mathfields to the DOM.

As far as I can tell, in React I'm only able to access / manipulate the MathView component via refs. Am I missing something?

Thanks,

Will

@arnog
Copy link
Owner

arnog commented Oct 31, 2022

I'm not sure what you are asking. Are you asking how to make the call to makeSharedVirtualKeyboard() when using React? I'm not a React expert, but I believe you would use the useEffect hook, i.e. something like:

import React, {useEffect} from 'react';

useEffect(()=> makeSharedVirtualKeyboard(),[])

@hobo1618
Copy link
Author

hobo1618 commented Nov 2, 2022

Yes, that was basically my question and sorry that it wasn't very clear.

The issue, finally, was that react-math-view doesn't expose makeSharedVirtualKeyboard(), so I added mathlive as a dependency and imported it from there. After that I simply fired the function and the shared keyboard worked, without having to call the function from a useEffect hook. Here's an example repo that also shows how to customize the keyboard.

Love the project btw!

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

2 participants