Skip to content

Commit

Permalink
feat: added convenience methods onBtn* for Primary and Secondary mous…
Browse files Browse the repository at this point in the history
…e buttons
  • Loading branch information
AlmasB committed Apr 14, 2023
1 parent 47408e9 commit 6e3d3e8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fxgl/src/main/kotlin/com/almasb/fxgl/dsl/FXGL.kt
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,14 @@ class FXGL private constructor() { companion object {
}, key)
}

@JvmStatic fun onBtnDownPrimary(action: Runnable) {
onBtnDown(MouseButton.PRIMARY, action)
}

@JvmStatic fun onBtnDownSecondary(action: Runnable) {
onBtnDown(MouseButton.SECONDARY, action)
}

@JvmStatic fun onBtnDown(btn: MouseButton, action: Runnable) {
onBtnDown(btn, "action${actionCounter++}", action)
}
Expand All @@ -519,6 +527,14 @@ class FXGL private constructor() { companion object {
}, btn)
}

@JvmStatic fun onBtnPrimary(action: Runnable) {
onBtn(MouseButton.PRIMARY, action)
}

@JvmStatic fun onBtnSecondary(action: Runnable) {
onBtn(MouseButton.SECONDARY, action)
}

@JvmStatic fun onBtn(btn: MouseButton, action: Runnable) {
onBtn(btn, "action${actionCounter++}", action)
}
Expand Down

0 comments on commit 6e3d3e8

Please sign in to comment.