Ejemplo n.º 1
0
 void insertText(String ins) {
   int i = text.getCursorPos();
   String left = text.getText().substring(0, i);
   String right = text.getText().substring(i, text.getText().length());
   text.setText(left + ins + right);
   this.data.content = text.getText();
 }
  public void insertText(final String text, final boolean isSpecialPaste) {
    String textToInsert = text;
    final int i = textArea.getCursorPos();
    final String left = textArea.getText().substring(0, i);
    final String right = textArea.getText().substring(i, textArea.getText().length());

    int cursorPosition = left.toCharArray().length;
    if (isSpecialPaste) {
      int p = text.indexOf("|");
      if (p > -1) {
        cursorPosition += p;
        textToInsert = textToInsert.replaceAll("\\|", "");
      }
    }

    textArea.setFocus(true);
    textArea.setText(left + textToInsert + right);
    textArea.setCursorPos(cursorPosition);
  }
  void insertText(String ins, boolean isSpecialPaste) {

    text.setFocus(true);

    int i = text.getCursorPos();
    String left = text.getText().substring(0, i);
    String right = text.getText().substring(i, text.getText().length());
    int cursorPosition = left.toCharArray().length;
    if (isSpecialPaste) {
      int p = ins.indexOf("|");
      if (p > -1) {
        cursorPosition += p;
        ins = ins.replaceAll("\\|", "");
      }
    }

    text.setText(left + ins + right);
    this.data.content = text.getText();

    text.setCursorPos(cursorPosition);
  }