SelectionRegistrant mixin

Mixin a render object can apply to handle SelectionRegistrar add/remove around the framework lifecycle.

Subclasses still need to implement the Selectable contract itself — this mixin only provides the bookkeeping for attach/detach against the ambient registrar.

Typical use:

class RenderText extends RenderObject
    with SelectionRegistrant
    implements Selectable { ... }

Then in the widget that wraps the render object:

@override
void updateRenderObject(BuildContext context, RenderText r) {
  r.attachToSelection(SelectionScope.maybeOf(context));
}

Calling attachToSelection is idempotent: if the registrar hasn't changed, no add/remove happens.

Implemented types
Mixin applications

Properties

cellBounds → CellRect?
The leaf's full painted rect in screen coordinates, including any portion currently scrolled off (or otherwise clipped). The registrar uses this for reading-order sort — content that's scrolled out of view still sorts at its logical position so the joined clipboard text comes out in the right order.
no setterinherited
contentLength → int
Number of cells of selectable content this leaf holds. Used by the registrar to bound granular events ("select word at offset 5 out of 30") and to validate selection ranges.
no setterinherited
geometry → SelectionGeometry
Live geometry — what portion of this leaf is currently selected. Implementations should notify() whenever this value changes.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
visibleBounds → CellRect?
The currently-visible portion of cellBounds — the intersection with all ancestor clip rects. Null when the Selectable is fully clipped (e.g. scrolled off-screen) OR when it hasn't painted yet. Used by visibility-aware code paths like auto-scroll edge detection; consumers that just want "where does this content belong in the document?" should use cellBounds.
no setterinherited

Methods

addListener(VoidCallback listener) → void
Registers listener to be called when this object changes.
inherited
attachToSelection(SelectionRegistrar? registrar) → void
Wires this Selectable to a (possibly null) registrar — pulling it from a previous registrar if one was attached. The owning widget should call this from updateRenderObject so the Selectable always follows whichever SelectionScope is currently in context.
detachFromSelection() → void
Called by the owning widget at dispose time. Cleans up the registration so the area doesn't hold a dangling reference.
dispatchSelectionEvent(SelectionEvent event) → SelectionResult
Processes a SelectionEvent, updating internal state. Returns a SelectionResult telling the parent container where the event's target sits relative to this leaf (used to walk to the next or previous Selectable when the live edge crosses a boundary).
inherited
getSelectedContent() → SelectedContent?
Returns the currently-selected portion of this leaf's content, or null if geometry reports nothing selected.
inherited
getSelectionRange() → ({int end, int start})?
Returns the absolute (start, end) range of the live selection as it sits inside this leaf's content (character offsets), or null when nothing is selected.
inherited
nextGraphemeBoundary(CellOffset from, int dCol, int dRow) → CellOffset?
Returns the screen-space cell position of the grapheme boundary nearest from, moved one grapheme in the given direction:
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeListener(VoidCallback listener) → void
Removes a previously-registered listener.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited