Kaluva Sireesha
Kaluva Sireesha

Reputation: 43

Implementing Keyboard interaction ctrl+a selects things out of paper in JointJS

Using keyboard interaction ctrl+a to select cells on paper, but it is selecting all the items on the page along with the cells on the paper. It is selecting as if using ctrl+a on normal web page where it selects the whole page. Some one please guide me how to prevent this keyboard shortcut from selecting the entire page. I just want that to select the cells on the paper.

code I am trying:

var selectAll = keyboard.on('ctrl+a', selectAllHandler.bind(null, self));

function selectAllHandler(self) {
   self.StateViewModel.selectMultiple(
      self.ViewModel.nodes().concat(self.ViewModel.links()));
   return false;
}

Upvotes: 0

Views: 320

Answers (1)

cklam
cklam

Reputation: 156

Maybe a bit late for an answer but the keyboard event passes a KeyboardEvent argument. Calling preventDefault() will suppress the default action and so prevents the selection of any other item outside the paper.

keyboard.on('ctrl+a', function(e) { 
  ... // select your cells and links

  e.preventDefault();
}

Upvotes: 1

Related Questions