Example #1
0
  /**
   * As adding focus handlers to JavaScript code would be too complex, let's do it even before they
   * actually get focus, i.e. make a method that triggers focus, and then override it if necessary
   *
   * @param b focus (false: blur)
   */
  public void setFocus(boolean b) {
    MathQuillHelper.focusEquationMathQuillGGB(component.getLaTeXElement(), b);

    // as the focus operation sometimes also scrolls
    // if (b)
    // geogebra.html5.main.DrawEquationWeb.scrollCursorIntoView(this,
    // seMayLatex);
    // put to focus handler
  }
Example #2
0
 public void setText(String s, boolean shallfocus) {
   String slatex = historyMap.get(s);
   if (slatex == null) {
     slatex = s;
   }
   Log.debug("HIST READ" + slatex + "," + s);
   if (slatex != null) {
     slatex =
         slatex
             .replace("\\$", "\\dollar ")
             .replace("$", "\\dollar ")
             .replace("(", "\\left(")
             .replace(")", "\\right)")
             .replace("\\left\\left(", "\\left(")
             .replace("\\right\\right)", "\\right)");
   }
   MathQuillHelper.updateEditingMathQuillGGB(component.getLaTeXElement(), slatex, shallfocus);
 }
Example #3
0
  public void autocomplete(String sugg, boolean replace) {
    // For now, we can assume that sugg is in LaTeX format,
    // and if it will be wrong, we can revise it later
    // at the moment we shall focus on replacing the current
    // word in MathQuillGGB with it...

    // Although MathQuillGGB could compute the current word,
    // it might not be the same as the following, as
    // maybe it can be done easily for English characters
    // but current word shall be internationalized to e.g.
    // Hungarian, or even Arabic, Korean, etc. which are
    // known by GeoGebra but unknown by MathQuillGGB...
    updateCurrentWord(false);
    String currentWord = curWord.toString();

    // So we also provide currentWord as a heuristic or helper:
    MathQuillHelper.writeLatexInPlaceOfCurrentWord(
        null, component.getLaTeXElement(), sugg, replace ? currentWord : "", true);

    // not to forget making the popup disappear after success!
    sug.hideSuggestions();
  }
Example #4
0
 public int getCaretPosition() {
   return MathQuillHelper.getCaretPosInEditedValue(component.getLaTeXElement());
 }