Skip to content

Commit 6e3d3e8

Browse files
committed
feat: added convenience methods onBtn* for Primary and Secondary mouse buttons
1 parent 47408e9 commit 6e3d3e8

File tree

1 file changed

+16
-0
lines changed
  • fxgl/src/main/kotlin/com/almasb/fxgl/dsl

1 file changed

+16
-0
lines changed

fxgl/src/main/kotlin/com/almasb/fxgl/dsl/FXGL.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ class FXGL private constructor() { companion object {
507507
}, key)
508508
}
509509

510+
@JvmStatic fun onBtnDownPrimary(action: Runnable) {
511+
onBtnDown(MouseButton.PRIMARY, action)
512+
}
513+
514+
@JvmStatic fun onBtnDownSecondary(action: Runnable) {
515+
onBtnDown(MouseButton.SECONDARY, action)
516+
}
517+
510518
@JvmStatic fun onBtnDown(btn: MouseButton, action: Runnable) {
511519
onBtnDown(btn, "action${actionCounter++}", action)
512520
}
@@ -519,6 +527,14 @@ class FXGL private constructor() { companion object {
519527
}, btn)
520528
}
521529

530+
@JvmStatic fun onBtnPrimary(action: Runnable) {
531+
onBtn(MouseButton.PRIMARY, action)
532+
}
533+
534+
@JvmStatic fun onBtnSecondary(action: Runnable) {
535+
onBtn(MouseButton.SECONDARY, action)
536+
}
537+
522538
@JvmStatic fun onBtn(btn: MouseButton, action: Runnable) {
523539
onBtn(btn, "action${actionCounter++}", action)
524540
}

0 commit comments

Comments
 (0)