-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add events types to InteractionManager.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/pixi/externals/extensions/_InteractionManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package pixi.externals.extensions | ||
|
||
import pixi.typings.ListenerFn | ||
import pixi.typings.interaction.InteractionEvent | ||
import pixi.typings.interaction.InteractionManager | ||
|
||
sealed interface InteractionManagerEvents<T> { | ||
object click : InteractionManagerEvents<InteractionEvent> | ||
object mousedown : InteractionManagerEvents<InteractionEvent> | ||
object mousemove : InteractionManagerEvents<InteractionEvent> | ||
object mouseout : InteractionManagerEvents<InteractionEvent> | ||
object mouseover : InteractionManagerEvents<InteractionEvent> | ||
object mouseup : InteractionManagerEvents<InteractionEvent> | ||
object mouseupoutside : InteractionManagerEvents<InteractionEvent> | ||
object pointercancel : InteractionManagerEvents<InteractionEvent> | ||
object pointerdown : InteractionManagerEvents<InteractionEvent> | ||
object pointermove : InteractionManagerEvents<InteractionEvent> | ||
object pointerout : InteractionManagerEvents<InteractionEvent> | ||
object pointerover : InteractionManagerEvents<InteractionEvent> | ||
object pointertap : InteractionManagerEvents<InteractionEvent> | ||
object pointerup : InteractionManagerEvents<InteractionEvent> | ||
object pointerupoutside : InteractionManagerEvents<InteractionEvent> | ||
object rightclick : InteractionManagerEvents<InteractionEvent> | ||
object rightdown : InteractionManagerEvents<InteractionEvent> | ||
object rightup : InteractionManagerEvents<InteractionEvent> | ||
object rightupoutside : InteractionManagerEvents<InteractionEvent> | ||
object tap : InteractionManagerEvents<InteractionEvent> | ||
object touchcancel : InteractionManagerEvents<InteractionEvent> | ||
object touchend : InteractionManagerEvents<InteractionEvent> | ||
object touchendoutside : InteractionManagerEvents<InteractionEvent> | ||
object touchmove : InteractionManagerEvents<InteractionEvent> | ||
object touchstart : InteractionManagerEvents<InteractionEvent> | ||
} | ||
|
||
inline fun <reified T : InteractionManagerEvents<*>> InteractionManager.emit(vararg arguments: T) = emit(T::class.simpleName!!, arguments as Array<Any?>) | ||
fun <T : Any> InteractionManager.on(event: InteractionManagerEvents<T>, callback: (T) -> Unit) = on(event::class.simpleName!!, callback as ListenerFn, null) | ||
fun <T : Any> InteractionManager.once(event: InteractionManagerEvents<T>, callback: (T) -> Unit) = once(event::class.simpleName!!, callback as ListenerFn, null) | ||
fun <T : Any> InteractionManager.off(event: InteractionManagerEvents<T>, callback: (T) -> Unit) = off(event::class.simpleName!!, callback as ListenerFn, null) | ||
|