Widget _buildHandle(BuildContext context, _TextSelectionHandlePosition position) { if ((_selection.isCollapsed && position == _TextSelectionHandlePosition.end) || selectionControls == null) { return(new Container()); // hide the second handle when collapsed } return(new Visibility( visible: handlesVisible, child: new _TextSelectionHandleOverlay( onSelectionHandleChanged: (TextSelection newSelection) => { _handleSelectionHandleChanged(newSelection, position); }, onSelectionHandleTapped: onSelectionHandleTapped, startHandleLayerLink: startHandleLayerLink, endHandleLayerLink: endHandleLayerLink, renderObject: renderObject, selection: _selection, selectionControls: selectionControls, position: position, dragStartBehavior: dragStartBehavior ) )); }
void _handleSelectionHandleChanged(TextSelection newSelection, _TextSelectionHandlePosition position) { TextPosition textPosition = null; switch (position) { case _TextSelectionHandlePosition.start: textPosition = newSelection.basePos; break; case _TextSelectionHandlePosition.end: textPosition = newSelection.extendPos; break; } this.selectionDelegate.textEditingValue = this._value.copyWith(selection: newSelection, composing: TextRange.empty); this.selectionDelegate.bringIntoView(textPosition); }
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; }
Widget _buildHandle(BuildContext context, _TextSelectionHandlePosition position) { if ((this._selection.isCollapsed && position == _TextSelectionHandlePosition.end) || this.selectionControls == null) { return(new Container()); // hide the second handle when collapsed } return(new _TextSelectionHandleOverlay( onSelectionHandleChanged: (TextSelection newSelection) => { this._handleSelectionHandleChanged(newSelection, position); }, onSelectionHandleTapped: this._handleSelectionHandleTapped, layerLink: this.layerLink, renderObject: this.renderObject, selection: this._selection, selectionControls: this.selectionControls, position: position, dragStartBehavior: this.dragStartBehavior )); }
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; }