Пример #1
0
 public TextInputConfiguration(
     TextInputType inputType               = null,
     bool obscureText                      = false,
     bool autocorrect                      = true,
     SmartDashesType?smartDashesType       = null,
     SmartQuotesType?smartQuotesType       = null,
     bool enableSuggestions                = true,
     string actionLabel                    = null,
     TextInputAction inputAction           = TextInputAction.done,
     ui.Brightness keyboardAppearance      = ui.Brightness.light,
     TextCapitalization textCapitalization = TextCapitalization.none,
     bool unityTouchKeyboard               = false
     )
 {
     D.assert(inputType != null);
     this.smartDashesType =
         smartDashesType ?? (obscureText ? SmartDashesType.disabled : SmartDashesType.enabled);
     this.smartQuotesType =
         smartQuotesType ?? (obscureText ? SmartQuotesType.disabled : SmartQuotesType.enabled);
     this.inputType          = inputType ?? TextInputType.text;
     this.obscureText        = obscureText;
     this.autocorrect        = autocorrect;
     this.enableSuggestions  = enableSuggestions;
     this.actionLabel        = actionLabel ?? "";
     this.inputAction        = inputAction;
     this.textCapitalization = textCapitalization;
     this.keyboardAppearance = keyboardAppearance;
     this.unityTouchKeyboard = unityTouchKeyboard;
 }
Пример #2
0
 public InputField(
     Key key = null,
     TextEditingController controller = null,
     FocusNode focusNode                       = null,
     bool obscureText                          = false,
     bool autocorrect                          = true,
     bool enabled                              = true,
     TextStyle style                           = null,
     TextAlign textAlign                       = TextAlign.left,
     int maxLines                              = 1,
     bool autofocus                            = false,
     string hintText                           = null,
     TextStyle hintStyle                       = null,
     string labelText                          = null,
     TextStyle labelStyle                      = null,
     Color cursorColor                         = null,
     float cursorWidth                         = 2,
     Radius cursorRadius                       = null,
     TextInputAction textInputAction           = TextInputAction.none,
     TextInputType keyboardType                = null,
     float height                              = 44.0f,
     InputFieldClearButtonMode clearButtonMode = InputFieldClearButtonMode.never,
     bool enableInteractiveSelection           = true,
     Color selectionColor                      = null,
     ValueChanged <string> onChanged           = null,
     ValueChanged <string> onSubmitted         = null,
     EdgeInsets scrollPadding                  = null
     ) : base(key)
 {
     this.controller                 = controller;
     this.textAlign                  = textAlign;
     this.focusNode                  = focusNode;
     this.obscureText                = obscureText;
     this.autocorrect                = autocorrect;
     this.enabled                    = enabled;
     this.style                      = style;
     this.textAlign                  = textAlign;
     this.maxLines                   = maxLines;
     this.autofocus                  = autofocus;
     this.hintText                   = hintText;
     this.hintStyle                  = hintStyle;
     this.labelText                  = labelText;
     this.labelStyle                 = labelStyle;
     this.height                     = height;
     this.clearButtonMode            = clearButtonMode;
     this.enableInteractiveSelection = enableInteractiveSelection;
     this.selectionColor             = selectionColor ?? new Color(0x667FAACF);
     this.cursorColor                = cursorColor;
     this.cursorWidth                = cursorWidth;
     this.cursorRadius               = cursorRadius ?? Radius.circular(1.0f);
     this.textInputAction            = textInputAction;
     this.keyboardType               = keyboardType;
     this.onChanged                  = onChanged;
     this.onSubmitted                = onSubmitted;
     this.scrollPadding              = scrollPadding;
 }
Пример #3
0
 public SearchDelegate(
     string searchFieldLabel         = null,
     TextInputType keyboardType      = null,
     TextInputAction textInputAction = TextInputAction.search
     )
 {
     this.searchFieldLabel = searchFieldLabel;
     this.keyboardType     = keyboardType;
     this.textInputAction  = textInputAction;
 }
Пример #4
0
        internal static void _performAction(int client, TextInputAction action)
        {
            if (_currentConnection == null)
            {
                return;
            }

            if (client != _currentConnection._id)
            {
                return;
            }

            _currentConnection._client.performAction(action);
        }
Пример #5
0
        internal void _performAction(int client, TextInputAction action)
        {
            if (this._currentConnection == null)
            {
                return;
            }

            if (client != this._currentConnection._id)
            {
                return;
            }

            this._currentConnection._client.performAction(action);
        }
Пример #6
0
        public void performAction(TextInputAction action)
        {
            TextEditingValue newValue;

            switch (action)
            {
            case TextInputAction.newline:
                if (this.widget.maxLines == 1)
                {
                    this._finalizeEditing(true);
                }

                break;

            case TextInputAction.done:
            case TextInputAction.go:
            case TextInputAction.send:
            case TextInputAction.search:
                this._finalizeEditing(true);
                break;

            case TextInputAction.next:
            case TextInputAction.previous:
            case TextInputAction.continueAction:
            case TextInputAction.join:
            case TextInputAction.route:
            case TextInputAction.emergencyCall:
                this._finalizeEditing(false);
                break;

            default:
                newValue = this.getValueForAction(action);
                if (newValue != this.textEditingValue)
                {
                    this.textEditingValue = newValue;
                }

                break;
            }
        }
Пример #7
0
        public void performAction(TextInputAction action)
        {
            switch (action)
            {
            case TextInputAction.newline:
                if (this.widget.maxLines == 1)
                {
                    this._finalizeEditing(true);
                }

                break;

            case TextInputAction.done:
            case TextInputAction.go:
            case TextInputAction.send:
            case TextInputAction.search:
                this._finalizeEditing(true);
                break;

            default:
                this._finalizeEditing(false);
                break;
            }
        }
Пример #8
0
 public TextInputConfiguration(TextInputType inputType               = null,
                               bool obscureText                      = false, bool autocorrect = true, TextInputAction inputAction = TextInputAction.done,
                               Brightness keyboardAppearance         = Brightness.light,
                               TextCapitalization textCapitalization = TextCapitalization.none,
                               bool unityTouchKeyboard               = false)
 {
     this.inputType          = inputType ?? TextInputType.text;
     this.inputAction        = inputAction;
     this.obscureText        = obscureText;
     this.autocorrect        = autocorrect;
     this.textCapitalization = textCapitalization;
     this.keyboardAppearance = keyboardAppearance;
     this.unityTouchKeyboard = unityTouchKeyboard;
 }
Пример #9
0
        public TextEditingValue getValueForAction(TextInputAction operation)
        {
            TextPosition     newPosition  = null;
            TextPosition     newExtend    = null;
            TextEditingValue newValue     = null;
            TextSelection    newSelection = null;
            TextPosition     startPos     = new TextPosition(this._value.selection.start, this._value.selection.affinity);

            switch (operation)
            {
            case TextInputAction.moveLeft:
                newValue = this._value.moveLeft();
                break;

            case TextInputAction.moveRight:
                newValue = this._value.moveRight();
                break;

            case TextInputAction.moveUp:
                newPosition = this.renderEditable.getPositionUp(startPos);
                break;

            case TextInputAction.moveDown:
                newPosition = this.renderEditable.getPositionDown(startPos);
                break;

            case TextInputAction.moveLineStart:
                newPosition = this.renderEditable.getParagraphStart(startPos, TextAffinity.downstream);
                break;

            case TextInputAction.moveLineEnd:
                newPosition = this.renderEditable.getParagraphEnd(startPos, TextAffinity.upstream);
                break;

            case TextInputAction.moveWordRight:
                newPosition = this.renderEditable.getWordRight(startPos);
                break;

            case TextInputAction.moveWordLeft:
                newPosition = this.renderEditable.getWordLeft(startPos);
                break;

//                case TextInputAction.MoveToStartOfNextWord:      MoveToStartOfNextWord(); break;
//                case TextInputAction.MoveToEndOfPreviousWord:        MoveToEndOfPreviousWord(); break;
            case TextInputAction.moveTextStart:
                newPosition = new TextPosition(0);
                break;

            case TextInputAction.moveTextEnd:
                newPosition = new TextPosition(this._value.text.Length);
                break;

            case TextInputAction.moveParagraphForward:
                newPosition = this.renderEditable.getParagraphForward(startPos);
                break;

            case TextInputAction.moveParagraphBackward:
                newPosition = this.renderEditable.getParagraphBackward(startPos);
                break;

            case TextInputAction.moveGraphicalLineStart:
                newPosition = this.renderEditable.getLineStartPosition(startPos, TextAffinity.downstream);
                break;

            case TextInputAction.moveGraphicalLineEnd:
                newPosition = this.renderEditable.getLineEndPosition(startPos, TextAffinity.upstream);
                break;

            case TextInputAction.selectLeft:
                newValue = this._value.extendLeft();
                break;

            case TextInputAction.selectRight:
                newValue = this._value.extendRight();
                break;

            case TextInputAction.selectUp:
                newExtend = this.renderEditable.getPositionUp(this._value.selection.extendPos);
                break;

            case TextInputAction.selectDown:
                newExtend = this.renderEditable.getPositionDown(this._value.selection.extendPos);
                break;

            case TextInputAction.selectWordRight:
                newExtend = this.renderEditable.getWordRight(this._value.selection.extendPos);
                break;

            case TextInputAction.selectWordLeft:
                newExtend = this.renderEditable.getWordLeft(this._value.selection.extendPos);
                break;

//                case TextInputAction.SelectToEndOfPreviousWord:  SelectToEndOfPreviousWord(); break;
//                case TextInputAction.SelectToStartOfNextWord:    SelectToStartOfNextWord(); break;
//
            case TextInputAction.selectTextStart:
                newExtend = new TextPosition(0);
                break;

            case TextInputAction.selectTextEnd:
                newExtend = new TextPosition(this._value.text.Length);
                break;

            case TextInputAction.expandSelectGraphicalLineStart:
                if (this._value.selection.isCollapsed ||
                    !this.renderEditable.isLineEndOrStart(this._value.selection.start))
                {
                    newSelection = new TextSelection(this.renderEditable.getLineStartPosition(startPos).offset,
                                                     this._value.selection.end, this._value.selection.affinity);
                }

                break;

            case TextInputAction.expandSelectGraphicalLineEnd:
                if (this._value.selection.isCollapsed ||
                    !this.renderEditable.isLineEndOrStart(this._value.selection.end))
                {
                    newSelection = new TextSelection(this._value.selection.start,
                                                     this.renderEditable.getLineEndPosition(this._value.selection.endPos).offset,
                                                     this._value.selection.affinity);
                }

                break;

            case TextInputAction.selectParagraphForward:
                newExtend = this.renderEditable.getParagraphForward(this._value.selection.extendPos);
                break;

            case TextInputAction.selectParagraphBackward:
                newExtend = this.renderEditable.getParagraphBackward(this._value.selection.extendPos);
                break;

            case TextInputAction.selectGraphicalLineStart:
                newExtend = this.renderEditable.getLineStartPosition(this._value.selection.extendPos);
                break;

            case TextInputAction.selectGraphicalLineEnd:
                newExtend = this.renderEditable.getLineEndPosition(startPos);
                break;

            case TextInputAction.delete:
                newValue = this._value.deleteSelection(false);
                break;

            case TextInputAction.backspace:
                newValue = this._value.deleteSelection();
                break;

            case TextInputAction.selectAll:
                newSelection = this._value.selection.copyWith(baseOffset: 0, extentOffset: this._value.text.Length);
                break;
            }

            if (newPosition != null)
            {
                return(this._value.copyWith(selection: TextSelection.fromPosition(newPosition)));
            }
            else if (newExtend != null)
            {
                return(this._value.copyWith(selection: this._value.selection.copyWith(extentOffset: newExtend.offset)));
            }
            else if (newSelection != null)
            {
                return(this._value.copyWith(selection: newSelection));
            }
            else if (newValue != null)
            {
                return(newValue);
            }

            return(this._value);
        }
Пример #10
0
 static void mapKey(string key, TextInputAction action)
 {
     _keyToOperations[Event.KeyboardEvent(key)] = action;
 }
Пример #11
0
 public InputField(
     Key key = null,
     TextEditingController controller = null,
     FocusNode focusNode    = null,
     bool obscureText       = false,
     bool autocorrect       = true,
     bool enabled           = true,
     Decoration decoration  = null,
     TextStyle style        = null,
     TextAlign textAlign    = TextAlign.left,
     Alignment alignment    = null,
     int?maxLines           = 1,
     int?minLines           = null,
     int?maxLength          = null,
     bool maxLengthEnforced = true,
     bool autofocus         = false,
     List <TextInputFormatter> inputFormatters = null,
     Widget prefix                   = null,
     Widget suffix                   = null,
     string hintText                 = null,
     float?hintTextWidth             = null,
     TextStyle hintStyle             = null,
     string labelText                = null,
     TextStyle labelStyle            = null,
     Color cursorColor               = null,
     float cursorWidth               = 2,
     Radius cursorRadius             = null,
     TextInputAction textInputAction = TextInputAction.none,
     TextInputType keyboardType      = null,
     float?height = 44.0f,
     InputFieldClearButtonMode clearButtonMode = InputFieldClearButtonMode.never,
     bool enableInteractiveSelection           = true,
     Color selectionColor              = null,
     ValueChanged <string> onChanged   = null,
     ValueChanged <string> onSubmitted = null,
     EdgeInsets scrollPadding          = null
     ) : base(key: key)
 {
     D.assert(maxLines == null || minLines == null || maxLines >= minLines);
     this.controller                 = controller;
     this.textAlign                  = textAlign;
     this.focusNode                  = focusNode;
     this.obscureText                = obscureText;
     this.autocorrect                = autocorrect;
     this.enabled                    = enabled;
     this.decoration                 = decoration;
     this.style                      = style;
     this.textAlign                  = textAlign;
     this.alignment                  = alignment ?? Alignment.center;
     this.maxLines                   = maxLines;
     this.minLines                   = minLines;
     this.maxLength                  = maxLength;
     this.maxLengthEnforced          = maxLengthEnforced;
     this.autofocus                  = autofocus;
     this.inputFormatters            = inputFormatters;
     this.prefix                     = prefix;
     this.suffix                     = suffix;
     this.hintText                   = hintText;
     this.hintTextWidth              = hintTextWidth;
     this.hintStyle                  = hintStyle;
     this.labelText                  = labelText;
     this.labelStyle                 = labelStyle;
     this.height                     = height;
     this.clearButtonMode            = clearButtonMode;
     this.enableInteractiveSelection = enableInteractiveSelection;
     this.selectionColor             = selectionColor ?? new Color(0x667FAACF);
     this.cursorColor                = cursorColor;
     this.cursorWidth                = cursorWidth;
     this.cursorRadius               = cursorRadius ?? Radius.circular(1.0f);
     this.textInputAction            = textInputAction;
     this.keyboardType               = keyboardType;
     this.onChanged                  = onChanged;
     this.onSubmitted                = onSubmitted;
     this.scrollPadding              = scrollPadding;
 }
Пример #12
0
 public TextInputConfiguration(TextInputType inputType = null,
                               bool obscureText        = false, bool autocorrect = true, TextInputAction inputAction = TextInputAction.done)
 {
     this.inputType   = inputType ?? TextInputType.text;
     this.inputAction = inputAction;
     this.obscureText = obscureText;
     this.autocorrect = autocorrect;
 }