/// <summary> /// Add a new listener to the handler. /// </summary> /// <param name="listener">The listener to add.</param> public void AddListener(MouseAxisListener listener) { if (listeners == null) { listeners = new List <MouseAxisListener>(); } listeners.Add(listener); }
/// <summary> /// Remove an existing listener from it's axis. /// </summary> /// <param name="axis">The axis to remove a listener from.</param> /// <param name="listener">The listener to remove.</param> public void RemoveListener(MouseAxis axis, MouseAxisListener listener) { if (axisHandlers != null) { for (int i = 0, axisHandlerCount = axisHandlers.Count; i < axisHandlerCount; i++) { if (axisHandlers[i].Axis == axis) { axisHandlers[i].RemoveListener(listener); return; } } } }
/// <summary> /// Remove a specific listener from the handler. /// </summary> /// <param name="listener">The listener to remove.</param> public void RemoveListener(MouseAxisListener listener) { if (listener != null) { for (int i = 0, listenerCount = listeners.Count; i < listenerCount; i++) { if (listeners[i] == listener) { listeners.RemoveAt(i); break; } } } }
/// <summary> /// Add a new axis event listener to the specific mouse /// axis. /// </summary> /// <param name="axis">The axis to listen to.</param> /// <param name="listener">The listener to notify.</param> public void AddListener(MouseAxis axis, MouseAxisListener listener) { if (axisHandlers != null) { for (int i = 0, axisHandlerCount = axisHandlers.Count; i < axisHandlerCount; i++) { if (axisHandlers[i].Axis == axis) { axisHandlers[i].AddListener(listener); return; } } } else { axisHandlers = new List <MouseAxisHandler>(); } MouseAxisHandler axisHandler = new MouseAxisHandler(axis); axisHandler.AddListener(listener); axisHandlers.Add(axisHandler); }