mathquill latex- how can I move cursor (selection) by code?

巧了我就是萌 提交于 2019-12-01 10:24:23

问题


I am using mathquill lib (mathquill git) and I am trying to make a keypad and a backspace using html buttons but I can't figure out how to move the cursor throw the formula.

Thanks,


回答1:


You can trigger custom keydown event on textarea within mathquill to move cursor through formula.

var customKeyDownEvent = $.Event('keydown');

customKeyDownEvent.bubbles = true;
customKeyDownEvent.cancelable =true;
customKeyDownEvent.charCode = 37;  // 37 for left arrow key
customKeyDownEvent.keyCode = 37;   
customKeyDownEvent.which = 37;

$('.mathquill-editable textarea').trigger(customKeyDownEvent);

Use charCode / keyCode / which are:

  1. 37 for left arrow key
  2. 39 for right arrow key

Thanks.



来源:https://stackoverflow.com/questions/27342276/mathquill-latex-how-can-i-move-cursor-selection-by-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!