Skip to content

API reference

cy.boxSelectionMode — Core > Interaction controls. Cytoscape.js signatures, parameters and return contract.

cy.boxSelectionMode — Core › Interaction controls

Preview · Core › Interaction controls

Read in the complete API reference · All API members

#cy.boxSelectionMode()

// What the box-selection gesture counts as caught: 'contain' (default) selects only elements wholly inside the band; 'overlap' selects anything the band touches — a node whose box intersects it, an edge any part of whose drawn path crosses it.
cy.boxSelectionMode(): BoxSelectionMode

What the box-selection gesture counts as caught: 'contain' (default) selects only elements wholly inside the band; 'overlap' selects anything the band touches — a node whose box intersects it, an edge any part of whose drawn path crosses it..

Two notes on the boundary. This setting is read by the gesture only: cy.elementsInBox() stays the pure geometric containment query it has always been, so a programmatic caller's results do not change under this setting. And boxSelectionIncludesLabels reverses sense with the mode, because it can only mean one thing in each: under 'contain' the label box must also be inside, under 'overlap' a label that crosses the band is enough.

Returns BoxSelectionMode

the current boxSelectionMode value

Example

console.log(cy.boxSelectionMode()); // "contain"

Example graph and handle setup

#cy.boxSelectionMode(mode)

// What the box-selection gesture counts as caught: 'contain' (default) selects only elements wholly inside the band; 'overlap' selects anything the band touches — a node whose box intersects it, an edge any part of whose drawn path crosses it.
cy.boxSelectionMode(mode: BoxSelectionMode): this

What the box-selection gesture counts as caught: 'contain' (default) selects only elements wholly inside the band; 'overlap' selects anything the band touches — a node whose box intersects it, an edge any part of whose drawn path crosses it..

Two notes on the boundary. This setting is read by the gesture only: cy.elementsInBox() stays the pure geometric containment query it has always been, so a programmatic caller's results do not change under this setting. And boxSelectionIncludesLabels reverses sense with the mode, because it can only mean one thing in each: under 'contain' the label box must also be inside, under 'overlap' a label that crosses the band is enough.

Parameters
NameDescription
mode: BoxSelectionMode

the new mode

Returns this

this core, for chaining

Example

const result = cy.boxSelectionMode("contain");
console.log(result === cy); // true

Example graph and handle setup

Throws

if mode is neither 'contain' nor 'overlap'