# all files / Github/diagram-js/lib/util/ Mouse.js

55.56% Statements 5/9
33.33% Branches 4/12
66.67% Functions 2/3
55.56% Lines 5/9

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39

    14×

    14×

    14×

    14×
    14×

     import {
      getOriginal as getOriginalEvent
    } from './Event';

    import {
      isMac
    } from './Platform';

    export {
      isMac
    } from './Platform';

    export function isPrimaryButton(event) {
      // button === 0 -> left áka primary mouse button
      return !(getOriginalEvent(event) || event).button;
    }

    export function hasPrimaryModifier(event) {
      var originalEvent = getOriginalEvent(event) || event;

      Iif (!isPrimaryButton(event)) {
        return false;
      }

      // Use alt as primary modifier key for mac OS
      Eif (isMac()) {
        return originalEvent.metaKey;
      } else {
        return originalEvent.ctrlKey;
      }
    }

    export function hasSecondaryModifier(event) {
      var originalEvent = getOriginalEvent(event) || event;

      return isPrimaryButton(event) && originalEvent.shiftKey;
    }