brows3r — TypeScript API
    Preparing search index...

    Interface UseSelectionResult<T>

    interface UseSelectionResult<T> {
        cursor: number;
        isSelected: (id: string) => boolean;
        onClick: (item: T, index: number, e: MouseEvent) => void;
        onContextMenu: (item: T, index: number, e: MouseEvent) => void;
        onKeyDown: (e: KeyboardEvent) => void;
        selection: SelectionModel<T>;
        setCursor: (index: number) => void;
    }

    Type Parameters

    • T
    Index

    Properties

    cursor: number

    Cursor index (highlighted row; moves with keyboard nav).

    isSelected: (id: string) => boolean
    onClick: (item: T, index: number, e: MouseEvent) => void

    Call from a row's onClick handler with the item and the event.

    onContextMenu: (item: T, index: number, e: MouseEvent) => void

    Call from a row's onContextMenu handler. Mirrors Finder/Explorer behaviour: right-clicking on an unselected row replaces selection with just that row so the context menu acts on a sensible target. Right- clicking on an already-selected row leaves the selection untouched (so multi-select operations work).

    onKeyDown: (e: KeyboardEvent) => void

    Bind to the list container's onKeyDown for Cmd/Ctrl+A.

    selection: SelectionModel<T>
    setCursor: (index: number) => void