Cloud Development Kit

How to use Delete() Method?

Hey,

I am using the web text javascript plugin and I would like to clear the canvas if the user draws a specific word, but I dont know how to use the delete() method mentioned in the documentation here. I guess I need to use it like object.delete(), but how do I get this object?

Thanks for your help.
Best regards.


Dear Anja,

thank you for your question.

Actually, the easiest way to see how to implement the delete function consists in saving the sample locally on your computer: sample.

Once saved, edit the html file, and you will see how the delete, undo, redo ... functions are implemented.

Basically, this is done as follows: <paper-fab elevation=1 aria-disabled=false animated= tabindex=0 role=button class=delete style-scope myscript-text-web x-scope paper-fab-0 mini= icon=delete title=delete>

You should of course ensure to call the webcomponents-lite.js JS library.

Then, when getting the TEXT result you expect, you should just call the delete function.

Let us know if you have further questions.

Best regards,

Olivier

Hello, I am trying to use the delete() function inside my js, but there is no way I could achieve it. I don't know how to do it. One way I could do it was by $('.delete').click(). But, it does not work on web apps (cordova and ionic). Please, could you help me? I really need it working as soon as possible. Thank you for helping me.

Dear Felipe,

thank you for your question.

Normally, there should not be major difficulty integrating the web components in Cordova (nevertheless it was not tested on our side).

Did you allow the network access in your cordova application? Are you able to use other functions of the web components? Is it possible to learn more about your implementation? Is recognition working properly?

Best regards,

Olivier

Dear Felipe,

can you confirm after sending the ink to the MyScript Cloud you are getting a recognition result?

If not, can you please ensure your application has the right to send http data?

Best regards,

Olivier

Hello, Olivier.
Thank you for your reply.
The MyScript Cloud is working properly.
The unique problem is that I don't know how to call the delete function.
If I press the delete button, it works. But, I cannot make it work by js.
About my implementation, I am working on a research project. It is an Intelligent Tutoring System (ITS) to Math, and I am integrating the handwriting recognition on it. So, from an initial equation, the student can enter steps to solve the equation, the system is going to check if the step is correct or not. If not, the ITS is going to give a hint to the student, telling him/her where and why it is wrong. If the step entered by the student is correct, the system allow him/her to go to the resolution of the next step. That is why I have to clean the canvas, by calling the delete function.
Once again, thank you so much for your help.
Sincerely,
Felipe de Morais

Dear Felipe,

thank you for the precision. If I understand well, the default sample works fine in the browser of your device.

Also, the recognition works fine in your application, and you are getting converted result? The only problem is how to call the delete function?

Then, if using the math API, this can be done callin document.querySelector('myscript-math-web').delete(). If using the text API, just proceed replacing the math by text.

Best regards,

Olivier

Dear Olivier.
Thank you so much for your help.
That is exactly what I was looking for.
You are the best.
Best regards,
Felipe de Morais

Dear Felipe,

thank you for the update, I am glad this works!

Best regards,

Olivier

Login or Signup to post a comment