getOpStateFromAction method

dynamic getOpStateFromAction(
  1. dynamic mouse,
  2. dynamic key
)

Get the operation associated to mouse and key combination and returns the corresponding FSA state @param {Number} mouse Mouse button @param {String} key Keyboard modifier @returns The FSA state obtained from the operation associated to mouse/keyboard combination

Implementation

getOpStateFromAction(mouse, key) {
  var action;

  for (var i = 0; i < mouseActions.length; i++) {
    action = mouseActions[i];
    if (action['mouse'] == mouse && action['key'] == key) {
      return action['state'];
    }
  }

  if (key != null) {
    for (var i = 0; i < mouseActions.length; i++) {
      action = mouseActions[i];
      if (action['mouse'] == mouse && action['key'] == null) {
        return action['state'];
      }
    }
  }

  return null;
}