diff --git a/lib/src/extended_editable_text.dart b/lib/src/extended_editable_text.dart index 4e417a7..5603faa 100644 --- a/lib/src/extended_editable_text.dart +++ b/lib/src/extended_editable_text.dart @@ -183,6 +183,7 @@ class ExtendedEditableText extends StatefulWidget { this.enableIMEPersonalizedLearning = true, this.showToolbarInWeb = false, this.scribbleEnabled = true, + this.customPasteAction = false, }) : assert(controller != null), assert(focusNode != null), assert(obscuringCharacter != null && obscuringCharacter.length == 1), @@ -1035,6 +1036,9 @@ class ExtendedEditableText extends StatefulWidget { /// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning} final bool enableIMEPersonalizedLearning; + ///Set to True if you want to monitor keyboard paste operations externally and handle them yourself + final bool customPasteAction; + // Infer the keyboard type of an `EditableText` if it's not specified. static TextInputType _inferKeyboardType({ required Iterable? autofillHints, @@ -1410,7 +1414,7 @@ class ExtendedEditableTextState extends State /// Paste text from [Clipboard]. @override Future pasteText(SelectionChangedCause cause) async { - if (widget.readOnly) { + if (widget.readOnly || widget.customPasteAction) { return; } final TextSelection selection = textEditingValue.selection; diff --git a/lib/src/extended_text_field.dart b/lib/src/extended_text_field.dart index 3fa51cd..3e89889 100644 --- a/lib/src/extended_text_field.dart +++ b/lib/src/extended_text_field.dart @@ -246,6 +246,7 @@ class ExtendedTextField extends StatefulWidget { this.scribbleEnabled = true, this.enableIMEPersonalizedLearning = true, this.shouldShowSelectionHandles, + this.customPasteAction = false, this.textSelectionGestureDetectorBuilder, }) : assert(textAlign != null), assert(readOnly != null), @@ -704,6 +705,9 @@ class ExtendedTextField extends StatefulWidget { /// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning} final bool enableIMEPersonalizedLearning; + ///Set to True if you want to monitor keyboard paste operations externally and handle them yourself + final bool customPasteAction; + @override ExtendedTextFieldState createState() => ExtendedTextFieldState(); @@ -1357,6 +1361,7 @@ class ExtendedTextFieldState extends State scribbleEnabled: widget.scribbleEnabled, enableIMEPersonalizedLearning: widget.enableIMEPersonalizedLearning, showToolbarInWeb: _selectionGestureDetectorBuilder.showToolbarInWeb, + customPasteAction: widget.customPasteAction, ), ), );