diff --git a/src/input/events/GAMEOBJECT_POINTER_WHEEL_EVENT.js b/src/input/events/GAMEOBJECT_POINTER_WHEEL_EVENT.js new file mode 100644 index 000000000..70904ef95 --- /dev/null +++ b/src/input/events/GAMEOBJECT_POINTER_WHEEL_EVENT.js @@ -0,0 +1,36 @@ +/** + * @author Richard Davey + * @copyright 2019 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Pointer Wheel Event. + * + * This event is dispatched by an interactive Game Object if a pointer has its wheel moved while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('wheel', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_POINTER_WHEEL + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {number} deltaX - The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {number} deltaY - The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * @param {number} deltaZ - The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'wheel'; diff --git a/src/input/events/GAMEOBJECT_WHEEL_EVENT.js b/src/input/events/GAMEOBJECT_WHEEL_EVENT.js new file mode 100644 index 000000000..9ff84615d --- /dev/null +++ b/src/input/events/GAMEOBJECT_WHEEL_EVENT.js @@ -0,0 +1,38 @@ +/** + * @author Richard Davey + * @copyright 2019 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Game Object Wheel Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel moved while over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectwheel', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#GAMEOBJECT_WHEEL + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object the pointer was over when the wheel changed. + * @param {number} deltaX - The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {number} deltaY - The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * @param {number} deltaZ - The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {Phaser.Types.Input.EventData} event - The Phaser input event. You can call `stopPropagation()` to halt it from going any further in the event flow. + */ +module.exports = 'gameobjectwheel'; diff --git a/src/input/events/POINTER_WHEEL_EVENT.js b/src/input/events/POINTER_WHEEL_EVENT.js new file mode 100644 index 000000000..40f37f5dd --- /dev/null +++ b/src/input/events/POINTER_WHEEL_EVENT.js @@ -0,0 +1,32 @@ +/** + * @author Richard Davey + * @copyright 2019 Photon Storm Ltd. + * @license {@link https://opensource.org/licenses/MIT|MIT License} + */ + +/** + * The Pointer Wheel Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer has its wheel updated. + * + * Listen to this event from within a Scene using: `this.input.on('wheel', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_WHEEL} + * 2. [GAMEOBJECT_WHEEL]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_WHEEL} + * 3. [POINTER_WHEEL]{@linkcode Phaser.Input.Events#event:POINTER_WHEEL} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + * + * @event Phaser.Input.Events#POINTER_WHEEL + * @since 3.18.0 + * + * @param {Phaser.Input.Pointer} pointer - The Pointer responsible for triggering this event. + * @param {Phaser.GameObjects.GameObject[]} currentlyOver - An array containing all interactive Game Objects that the pointer was over when the event was created. + * @param {number} deltaX - The horizontal scroll amount that occurred due to the user moving a mouse wheel or similar input device. + * @param {number} deltaY - The vertical scroll amount that occurred due to the user moving a mouse wheel or similar input device. This value will typically be less than 0 if the user scrolls up and greater than zero if scrolling down. + * @param {number} deltaZ - The z-axis scroll amount that occurred due to the user moving a mouse wheel or similar input device. + */ +module.exports = 'wheel'; diff --git a/src/input/events/index.js b/src/input/events/index.js index ecc3b1da0..68e4eef96 100644 --- a/src/input/events/index.js +++ b/src/input/events/index.js @@ -37,7 +37,9 @@ module.exports = { GAMEOBJECT_POINTER_OUT: require('./GAMEOBJECT_POINTER_OUT_EVENT'), GAMEOBJECT_POINTER_OVER: require('./GAMEOBJECT_POINTER_OVER_EVENT'), GAMEOBJECT_POINTER_UP: require('./GAMEOBJECT_POINTER_UP_EVENT'), + GAMEOBJECT_POINTER_WHEEL: require('./GAMEOBJECT_POINTER_WHEEL_EVENT'), GAMEOBJECT_UP: require('./GAMEOBJECT_UP_EVENT'), + GAMEOBJECT_WHEEL: require('./GAMEOBJECT_WHEEL_EVENT'), MANAGER_BOOT: require('./MANAGER_BOOT_EVENT'), MANAGER_PROCESS: require('./MANAGER_PROCESS_EVENT'), MANAGER_UPDATE: require('./MANAGER_UPDATE_EVENT'), @@ -48,6 +50,7 @@ module.exports = { POINTER_OVER: require('./POINTER_OVER_EVENT'), POINTER_UP: require('./POINTER_UP_EVENT'), POINTER_UP_OUTSIDE: require('./POINTER_UP_OUTSIDE_EVENT'), + POINTER_WHEEL: require('./POINTER_WHEEL_EVENT'), POINTERLOCK_CHANGE: require('./POINTERLOCK_CHANGE_EVENT'), PRE_UPDATE: require('./PRE_UPDATE_EVENT'), SHUTDOWN: require('./SHUTDOWN_EVENT'),