コード例 #1
0
        public TextSelectionOverlay(TextEditingValue value                  = null,
                                    BuildContext context                    = null, Widget debugRequiredFor = null,
                                    LayerLink layerLink                     = null,
                                    RenderEditable renderObject             = null,
                                    TextSelectionControls selectionControls = null,
                                    TextSelectionDelegate selectionDelegate = null,
                                    DragStartBehavior dragStartBehavior     = DragStartBehavior.start)
        {
            D.assert(value != null);
            D.assert(context != null);
            this.context           = context;
            this.debugRequiredFor  = debugRequiredFor;
            this.layerLink         = layerLink;
            this.renderObject      = renderObject;
            this.selectionControls = selectionControls;
            this.selectionDelegate = selectionDelegate;
            this._value            = value;
            OverlayState overlay = Overlay.of(context);

            D.assert(overlay != null, () => $"No Overlay widget exists above {context}.\n" +
                     "Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your " +
                     "app content was created above the Navigator with the WidgetsApp builder parameter.");
            this._toolbarController = new AnimationController(duration: fadeDuration, vsync: overlay);
            this.dragStartBehavior  = dragStartBehavior;
        }
コード例 #2
0
 internal _TextSelectionHandleOverlay(
     Key key = null,
     TextSelection selection = null,
     _TextSelectionHandlePosition position = _TextSelectionHandlePosition.start,
     LayerLink layerLink         = null,
     RenderEditable renderObject = null,
     ValueChanged <TextSelection> onSelectionHandleChanged = null,
     VoidCallback onSelectionHandleTapped    = null,
     TextSelectionControls selectionControls = null
     ) : base(key: key)
 {
     this.selection                = selection;
     this.position                 = position;
     this.layerLink                = layerLink;
     this.renderObject             = renderObject;
     this.onSelectionHandleChanged = onSelectionHandleChanged;
     this.onSelectionHandleTapped  = onSelectionHandleTapped;
     this.selectionControls        = selectionControls;
 }
コード例 #3
0
        public TextSelectionOverlay(TextEditingValue value                  = null,
                                    BuildContext context                    = null, Widget debugRequiredFor = null,
                                    LayerLink layerLink                     = null,
                                    RenderEditable renderObject             = null,
                                    TextSelectionControls selectionControls = null,
                                    TextSelectionDelegate selectionDelegate = null)
        {
            D.assert(value != null);
            D.assert(context != null);
            this.context           = context;
            this.debugRequiredFor  = debugRequiredFor;
            this.layerLink         = layerLink;
            this.renderObject      = renderObject;
            this.selectionControls = selectionControls;
            this.selectionDelegate = selectionDelegate;
            this._value            = value;
            OverlayState overlay = Overlay.of(context);

            D.assert(overlay != null);
            this._handleController  = new AnimationController(duration: _fadeDuration, vsync: overlay);
            this._toolbarController = new AnimationController(duration: _fadeDuration, vsync: overlay);
        }
コード例 #4
0
 internal _TextSelectionHandleOverlay(
     Key key = null,
     TextSelection selection = null,
     _TextSelectionHandlePosition position = _TextSelectionHandlePosition.start,
     LayerLink startHandleLayerLink        = null,
     LayerLink endHandleLayerLink          = null,
     RenderEditable renderObject           = null,
     ValueChanged <TextSelection> onSelectionHandleChanged = null,
     VoidCallback onSelectionHandleTapped    = null,
     TextSelectionControls selectionControls = null,
     DragStartBehavior dragStartBehavior     = DragStartBehavior.start
     ) : base(key: key)
 {
     this.selection                = selection;
     this.position                 = position;
     this.startHandleLayerLink     = startHandleLayerLink;
     this.endHandleLayerLink       = endHandleLayerLink;
     this.renderObject             = renderObject;
     this.onSelectionHandleChanged = onSelectionHandleChanged;
     this.onSelectionHandleTapped  = onSelectionHandleTapped;
     this.selectionControls        = selectionControls;
     this.dragStartBehavior        = dragStartBehavior;
 }
コード例 #5
0
        public TextSelectionOverlay(
            TextEditingValue value                  = null,
            BuildContext context                    = null,
            Widget debugRequiredFor                 = null,
            LayerLink toolbarLayerLink              = null,
            LayerLink startHandleLayerLink          = null,
            LayerLink endHandleLayerLink            = null,
            RenderEditable renderObject             = null,
            TextSelectionControls selectionControls = null,
            bool?handlesVisible = false,
            TextSelectionDelegate selectionDelegate = null,
            DragStartBehavior dragStartBehavior     = DragStartBehavior.start,
            VoidCallback onSelectionHandleTapped    = null)
        {
            D.assert(value != null);
            D.assert(context != null);
            D.assert(handlesVisible != null);
            _handlesVisible              = handlesVisible.Value;
            this.context                 = context;
            this.debugRequiredFor        = debugRequiredFor;
            this.toolbarLayerLink        = toolbarLayerLink;
            this.startHandleLayerLink    = startHandleLayerLink;
            this.endHandleLayerLink      = endHandleLayerLink;
            this.renderObject            = renderObject;
            this.selectionControls       = selectionControls;
            this.selectionDelegate       = selectionDelegate;
            this.onSelectionHandleTapped = onSelectionHandleTapped;
            _value = value;
            OverlayState overlay = Overlay.of(context, rootOverlay: true);

            D.assert(overlay != null, () => $"No Overlay widget exists above {context}.\n" +
                     "Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your " +
                     "app content was created above the Navigator with the WidgetsApp builder parameter.");
            _toolbarController     = new AnimationController(duration: fadeDuration, vsync: overlay);
            this.dragStartBehavior = dragStartBehavior;
        }
コード例 #6
0
ファイル: editable_text.cs プロジェクト: zmtzawqlp/UIWidgets
        void _handleSelectionChanged(TextSelection selection, RenderEditable renderObject,
                                     SelectionChangedCause cause)
        {
            this.widget.controller.selection = selection;
            this.requestKeyboard();

            this._hideSelectionOverlayIfNeeded();

            if (this.widget.selectionControls != null)
            {
                this._selectionOverlay = new TextSelectionOverlay(
                    context: this.context,
                    value: this._value,
                    debugRequiredFor: this.widget,
                    layerLink: this._layerLink,
                    renderObject: renderObject,
                    selectionControls: this.widget.selectionControls,
                    selectionDelegate: this
                    );
                bool longPress = cause == SelectionChangedCause.longPress;
                if (cause != SelectionChangedCause.keyboard && (this._value.text.isNotEmpty() || longPress))
                {
                    this._selectionOverlay.showHandles();
                }

                if (longPress || cause == SelectionChangedCause.doubleTap)
                {
                    this._selectionOverlay.showToolbar();
                }
            }

            if (this.widget.onSelectionChanged != null)
            {
                this.widget.onSelectionChanged(selection, cause);
            }
        }