iwicopd2
iwicopd2

Reputation: 87

How to know the index of a node selection in a multiple selection?

Suppose you enabled box selection in cytoscapejs or you do something like:

cy.nodes().select();

when the user clicks a button. So, the user is able to select multiple nodes at once.

When registering the handler for the select event on nodes:

cy.nodes().on('select', function(evt){
  ...
}

Is there any way to know if the selection of a node is due to:

  1. A single selection event (i.e. the user just clicked on a single node)?
  2. A multiple selection event (and which index the current node is in this multiple selection)

Thanks!

Upvotes: 0

Views: 235

Answers (1)

maxkfranz
maxkfranz

Reputation: 12250

You can track the events coming in to determine the type of selection (i.e. tap versus tapstart-tapdrag-tapend / tap versus box). You can keep a counter, declared outside the event callback, to track element indices if you want --- though the indicies won't really mean anything.

Upvotes: 0

Related Questions