MCPcopy Index your code
hub / github.com/bqplot/bqplot / click_handler

Method click_handler

js/src/Graph.ts:456–499  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

454 }
455
456 click_handler(args) {
457 const index = args.index;
458 const idx = this.model.get('selected') || [];
459 let selected = Array.from(idx);
460 const elem_index = selected.indexOf(index);
461 // Replacement for "Accel" modifier.
462 const accelKey = d3GetEvent().ctrlKey || d3GetEvent().metaKey;
463
464 if (elem_index > -1 && accelKey) {
465 // if the index is already selected and if accel key is
466 // pressed, remove the node from the list
467 selected.splice(elem_index, 1);
468 } else {
469 if (accelKey) {
470 //If accel is pressed and the bar is not already selected
471 //add the bar to the list of selected bars.
472 selected.push(index);
473 }
474 // updating the array containing the bar indexes selected
475 // and updating the style
476 else {
477 //if accel is not pressed, then clear the selected ones
478 //and set the current node to the selected
479 selected = [];
480 selected.push(index);
481 }
482 }
483 this.model.set('selected', selected.length === 0 ? null : selected, {
484 updated_view: this,
485 });
486 this.touch();
487 let e = d3GetEvent();
488 if (!e) {
489 e = window.event;
490 }
491 if (e.cancelBubble !== undefined) {
492 // IE
493 e.cancelBubble = true;
494 }
495 if (e.stopPropagation) {
496 e.stopPropagation();
497 }
498 e.preventDefault();
499 }
500
501 hovered_style_updated(model, style) {
502 this.hovered_style = style;

Callers

nothing calls this directly

Calls 1

d3GetEventFunction · 0.90

Tested by

no test coverage detected