Skip to content

Commit

Permalink
feat: Add events types to InteractionManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayfri committed Feb 15, 2022
1 parent 6f04dc0 commit b13cc27
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/kotlin/pixi/externals/extensions/_InteractionManager.kt
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)

0 comments on commit b13cc27

Please sign in to comment.