fixed a bug where text buttons won't respond immediately/esc menu text button to unintentionally "click" the newly-appeared button (ESC -> Return to Main Menu -> Cancel -> Return to ... )

This commit is contained in:
minjaesong
2021-09-17 23:52:10 +09:00
parent 575ed4410b
commit e22518530d
4 changed files with 34 additions and 26 deletions

View File

@@ -57,7 +57,7 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
abstract val width: Int
abstract val height: Int
private val mouseButton = App.getConfigInt("config_mouseprimary")
protected val mouseButton = App.getConfigInt("config_mouseprimary")
/** This variable is NOT updated on its own.
* ```
@@ -91,18 +91,9 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
/** If mouse is hovering over it and mouse is down */
open val mousePushed: Boolean
get() = mouseUp && Gdx.input.isButtonPressed(mouseButton)
/** If mouse is just pushed */
open val mouseJustPushed: Boolean
get() {
if (mouseUp && !mouseLatched && Gdx.input.isButtonJustPressed(mouseButton)) {
mouseLatched = true
return true
}
return false
}
private var mouseLatched = false
private var mouseLatched = Gdx.input.isButtonPressed(mouseButton)
/** UI to call (show up) while mouse is up */
open val mouseOverCall: UICanvas? = null
@@ -132,6 +123,10 @@ abstract class UIItem(var parentUI: UICanvas, val initialX: Int, val initialY: I
open var controllerInFocus = false
open fun show() {}
open fun hide() {}
open fun update(delta: Float) {
if (parentUI.isVisible) {
if (updateListener != null) {