handleSdlEvent method

  1. @override
void handleSdlEvent(
  1. Event event
)
override

Handle text editing events from SDL.

Implementation

@override
void handleSdlEvent(final Event event) {
  if (event is TextInputEvent) {
    appendText(event.text);
  } else if (event is KeyboardEvent &&
      event.state == PressedState.pressed &&
      event.key.modifiers.isEmpty) {
    final scanCode = event.key.scancode;
    if (scanCode == doneScanCode) {
      onDone(text);
    } else if (scanCode == cancelScanCode) {
      cancel();
    } else if (scanCode == backspaceScanCode) {
      backspace();
    } else {
      super.handleSdlEvent(event);
    }
  } else if (event is ControllerButtonEvent) {
    final button = event.button;
    if (button == shiftButton) {
      shiftPressed = event.state == PressedState.pressed;
    } else if (event.state == PressedState.pressed) {
      if (button == typeButton) {
        type();
      } else if (button == upButton) {
        moveUp();
      } else if (button == downButton) {
        moveDown();
      } else if (button == leftButton) {
        moveLeft();
      } else if (button == rightButton) {
        moveRight();
      } else if (button == doneButton) {
        onDone(text);
      } else if (button == cancelButton) {
        cancel();
      } else if (button == backspaceButton) {
        backspace();
      } else if (button == spaceButton) {
        appendText(' ');
      }
    }
  } else if (event is ControllerAxisEvent) {
    controllerAxisDispatcher.handleAxisValue(event.axis, event.smallValue);
  } else {
    super.handleSdlEvent(event);
  }
}