performSelector method

  1. @override
void performSelector(
  1. String selectorName
)
override

Performs the specified MacOS-specific selector from the NSStandardKeyBindingResponding protocol or user-specified selector from DefaultKeyBinding.Dict.

Implementation

@override
void performSelector(String selectorName) {
  final currentTextEditingValue = this.currentTextEditingValue;
  if (currentTextEditingValue == null) {
    return;
  }
  // magic string from flutter callback
  if (selectorName == 'deleteBackward:') {
    final oldText = currentTextEditingValue.text;
    final selection = currentTextEditingValue.selection;
    final deleteRange = selection.isCollapsed
        ? TextRange(
            start: selection.start - 1,
            end: selection.end,
          )
        : selection;
    onDelete(
      TextEditingDeltaDeletion(
        oldText: oldText,
        deletedRange: deleteRange,
        selection: const TextSelection.collapsed(
          offset: -1,
        ), // just pass a invalid value, because we don't use this selection inside.
        composing: TextRange.empty,
      ),
    );
  }
}