Math

Answered

A crash appears when you click to convert, please help to deal with it, thank you。

Dear MyScript :


A crash appears when you click to convert, please help to deal with it, thank you。

 

First open the ERASER function in InputController.java, as shown below:

image


Then write the formula (or percent sign, root sign) on the Math interface, and then use the eraser to erase the light gray content, as shown in the red box below:

image


Then click the convert button to appear the crash, the crash is as follows:

image



Thank you,

Best regards,

 

longjunhao

  



Best Answer

Dear Longjunhao


Thank you for your update. 

I was mislead as the issue is not present with a math part in the GetStarted example. But, I was able to reproduce your issue with the demo example.

This issue is fixed in the next iink release that should be launched within the next few weeks.


In the meantime, if you only use Math in your application you might consider building your application based on the GetStarted example.


Best regards,


Gwenaëlle


Dear Long Junhao,


Thank you for contacting us.


I am not sure to understand what you want to do.

Depending whether you want to erase a stroke doing a gesture, of if you want a rubber:
-In the first case, doing an erasure or scratch out, it will normally erase the stroke out the box.
-In  the second case, your shall ensure the "iinkPointerType" to set the  iinkPointerType to "PointerType.ERASER". (not to use a MotionEvent). You can refer to following post:

-https://developer-support.myscript.com/support/discussions/topics/16000023289
-https://developer-support.myscript.com/support/discussions/topics/16000023229


Best regards,


Gwenaëlle

Dear Gwenaëlle,

 

 

Thank you for your reply

 

 

1. I have set the eraser mode by the following method: In the handleOnTouchForPointer function, set iinkPointerType to ERASER: iinkPointerType = PointerType.ERASER.

 

2. When I erase the calculation result in the eraser mode, such as the light gray content in the screenshot below, and then perform the convert operation, a crash will appear.

How can I solve this crash?

 

image

 

crash:

 

image



 

Best regards,

 

 

longjunhao


Do you understand my question? Our company wants to experience this function as soon as possible, looking forward to your support, thank you very much

Dear Long Junhao,


Thank you for your update.

We have not been able to reproduce your issue.


In order to implement a rubber, here is what you can do, starting from the GetStarted and UIReferenceImplementation:


In the UIReferenceImplementation InputController class, you can add a new input mode ERASER with following line

public static final int INPUT_MODE_ERASER = 3;

Then in the handleOnTouchForPointer method of the InputController you add the mapping between this new input mode and the corresponding PointerType


    if (inputMode == INPUT_MODE_FORCE_PEN)
    {
      iinkPointerType = PointerType.PEN;
    }
    else if (inputMode == INPUT_MODE_FORCE_TOUCH)
    {
      iinkPointerType = PointerType.TOUCH;
    }
    else if (inputMode == INPUT_MODE_ERASER)
    {
      iinkPointerType = PointerType.ERASER;
    }
   else
    


Then what you should do is when switching to this ERASER mode using for instance a new eraser button to switch from input pen to input eraser in the MainActivity, you would have to add a new case in the onClick method:


case R.id.button_input_mode_eraser:
  setInputMode(InputController.INPUT_MODE_ERASER);
break;


Best regards,


Gwenaëlle



Dear Gwenaëlle,

 

 

thank you for your help.

 

According to the plan you provided,I have successfully debugged in the demo. but when I am in ERASER mode, after deleting the "=3" in the screenshot below, and then clicking the "convert" button, the crash still appears. How can I avoid this crash?

image


The crash log is as follows:

 2020-07-09 10:31:43.409 5033-5033/com.myscript.iink.demo E/AndroidRuntime: FATAL EXCEPTION: main

    Process: com.myscript.iink.demo, PID: 5033

    java.lang.RuntimeException: internal error

        at com.myscript.iink.NativeFunctions.convert(Native Method)

        at com.myscript.iink.Editor.convert(Editor.java:904)

        at com.myscript.iink.demo.DocumentController.convert(DocumentController.java:380)

        at com.myscript.iink.demo.MainActivity.onOptionsItemSelected(MainActivity.java:224)

        at android.app.Activity.onMenuItemSelected(Activity.java:3464)

        at android.support.v4.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:436)

        at android.support.v7.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:196)

        at android.support.v7.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:109)

        at android.support.v7.app.AppCompatDelegateImpl.onMenuItemSelected(AppCompatDelegateImpl.java:888)

        at android.support.v7.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:840)

        at android.support.v7.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:158)

        at android.support.v7.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:991)

        at android.support.v7.view.menu.MenuPopup.onItemClick(MenuPopup.java:128)

        at android.widget.AdapterView.performItemClick(AdapterView.java:318)

        at android.widget.AbsListView.performItemClick(AbsListView.java:1181)

        at android.widget.AbsListView$PerformClick.run(AbsListView.java:3150)

        at android.os.Handler.handleCallback(Handler.java:790)

        at android.os.Handler.dispatchMessage(Handler.java:99)

        at android.os.Looper.loop(Looper.java:164)

        at android.app.ActivityThread.main(ActivityThread.java:6552)

        at java.lang.reflect.Method.invoke(Native Method)

        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)

        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)


 


 

 

Best regards,

 

longjunhao

Answer

Dear Longjunhao


Thank you for your update. 

I was mislead as the issue is not present with a math part in the GetStarted example. But, I was able to reproduce your issue with the demo example.

This issue is fixed in the next iink release that should be launched within the next few weeks.


In the meantime, if you only use Math in your application you might consider building your application based on the GetStarted example.


Best regards,


Gwenaëlle

  • Support
  • Forums
  • Math
  • A crash appears when you click to convert, please help to deal with it, thank you。