src/main/java/com/spinyowl/legui/component/misc/listener/textarea/TextAreaFieldCharEventListener.java
@Override
  public void process(CharEvent event) {
    TextAreaField textAreaField = (TextAreaField) event.getTargetComponent();
    if (textAreaField.isFocused() && textAreaField.isEditable() && !MOUSE_BUTTON_LEFT.isPressed()) {
      String str = cpToStr(event.getCodepoint());
      TextState textState = textAreaField.getTextState();
      int start = textAreaField.getStartSelectionIndex();
      int end = textAreaField.getEndSelectionIndex();
      if (start > end) {
        start = textAreaField.getEndSelectionIndex();
        end = textAreaField.getStartSelectionIndex();
      }
      if (start != end) {
        StringBuilder builder = new StringBuilder(textState.getText());
        builder.delete(start, end);
        textState.setText(builder.toString());
        textAreaField.setCaretPosition(start);
        textAreaField.setStartSelectionIndex(start);
        textAreaField.setEndSelectionIndex(start);
      }
      int caretPosition = textAreaField.getCaretPosition();
      StringBuilder builder = new StringBuilder(textState.getText());
      builder.insert(caretPosition, str);
      textState.setText(builder.toString());
      int newCaretPosition = caretPosition + str.length();
      textAreaField.setCaretPosition(newCaretPosition);
      textAreaField.setEndSelectionIndex(newCaretPosition);
      textAreaField.setStartSelectionIndex(newCaretPosition);

      EventProcessorProvider.getInstance().pushEvent(
          new TextAreaFieldUpdateEvent(textAreaField, event.getContext(), event.getFrame()));
    }
  }
/**
   * Used to handle {@link CharEvent}.
   *
   * @param event event to handle.
   */
Used to handle  CharEvent.
@param event event to handle.
Used to handle CharEvent . @param event event to handle .
@Override
  public void process(CharEvent event) {
    TextAreaField textAreaField = (TextAreaField) event.getTargetComponent();
    if (textAreaField.isFocused() && textAreaField.isEditable() && !MOUSE_BUTTON_LEFT.isPressed()) {
      String str = cpToStr(event.getCodepoint());
      TextState textState = textAreaField.getTextState();
      int start = textAreaField.getStartSelectionIndex();
      int end = textAreaField.getEndSelectionIndex();
      if (start > end) {
        start = textAreaField.getEndSelectionIndex();
        end = textAreaField.getStartSelectionIndex();
      }
      if (start != end) {
        StringBuilder builder = new StringBuilder(textState.getText());
        builder.delete(start, end);
        textState.setText(builder.toString());
        textAreaField.setCaretPosition(start);
        textAreaField.setStartSelectionIndex(start);
        textAreaField.setEndSelectionIndex(start);
      }
      int caretPosition = textAreaField.getCaretPosition();
      StringBuilder builder = new StringBuilder(textState.getText());
      builder.insert(caretPosition, str);
      textState.setText(builder.toString());
      int newCaretPosition = caretPosition + str.length();
      textAreaField.setCaretPosition(newCaretPosition);
      textAreaField.setEndSelectionIndex(newCaretPosition);
      textAreaField.setStartSelectionIndex(newCaretPosition);
      EventProcessorProvider.getInstance().pushEvent(
          new TextAreaFieldUpdateEvent(textAreaField, event.getContext(), event.getFrame()));
    }
  }
@ Override public void process ( CharEvent event ) { TextAreaField textAreaField = ( TextAreaField ) event . getTargetComponent ( ) ; if ( textAreaField . isFocused ( ) && textAreaField . isEditable ( ) && ! MOUSE_BUTTON_LEFT . isPressed ( ) ) { String str = cpToStr ( event . getCodepoint ( ) ) ; TextState textState = textAreaField . getTextState ( ) ; int start = textAreaField . getStartSelectionIndex ( ) ; int end = textAreaField . getEndSelectionIndex ( ) ; if ( start > end ) { start = textAreaField . getEndSelectionIndex ( ) ; end = textAreaField . getStartSelectionIndex ( ) ; } if ( start != end ) { StringBuilder builder = new StringBuilder ( textState . getText ( ) ) ; builder . delete ( start , end ) ; textState . setText ( builder . toString ( ) ) ; textAreaField . setCaretPosition ( start ) ; textAreaField . setStartSelectionIndex ( start ) ; textAreaField . setEndSelectionIndex ( start ) ; } int caretPosition = textAreaField . getCaretPosition ( ) ; StringBuilder builder = new StringBuilder ( textState . getText ( ) ) ; builder . insert ( caretPosition , str ) ; textState . setText ( builder . toString ( ) ) ; int newCaretPosition = caretPosition + str . length ( ) ; textAreaField . setCaretPosition ( newCaretPosition ) ; textAreaField . setEndSelectionIndex ( newCaretPosition ) ; textAreaField . setStartSelectionIndex ( newCaretPosition ) ; EventProcessorProvider . getInstance ( ) . pushEvent ( new TextAreaFieldUpdateEvent ( textAreaField , event . getContext ( ) , event . getFrame ( ) ) ) ; } }
Used to handle {@link CharEvent}.
Used to handle { @link CharEvent } .