mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-26 07:39:44 +07:00
Restore the button's style correctly (#7683)
This commit is contained in:
@ -46,12 +46,14 @@ private class RestorableTextButtonStyle(
|
|||||||
baseStyle: TextButtonStyle,
|
baseStyle: TextButtonStyle,
|
||||||
val restoreStyle: ButtonStyle
|
val restoreStyle: ButtonStyle
|
||||||
) : TextButtonStyle(baseStyle)
|
) : TextButtonStyle(baseStyle)
|
||||||
|
|
||||||
/** Disable a [Button] by setting its [touchable][Button.touchable] and [color][Button.color] properties. */
|
/** Disable a [Button] by setting its [touchable][Button.touchable] and [color][Button.color] properties. */
|
||||||
fun Button.disable() {
|
fun Button.disable() {
|
||||||
touchable= Touchable.disabled
|
touchable = Touchable.disabled
|
||||||
val oldStyle = style
|
val oldStyle = style
|
||||||
val disabledStyle = BaseScreen.skin.get("disabled", TextButtonStyle::class.java)
|
val disabledStyle = BaseScreen.skin.get("disabled", TextButtonStyle::class.java)
|
||||||
style = RestorableTextButtonStyle(disabledStyle, oldStyle)
|
if (oldStyle !is RestorableTextButtonStyle)
|
||||||
|
style = RestorableTextButtonStyle(disabledStyle, oldStyle)
|
||||||
}
|
}
|
||||||
/** Enable a [Button] by setting its [touchable][Button.touchable] and [color][Button.color] properties. */
|
/** Enable a [Button] by setting its [touchable][Button.touchable] and [color][Button.color] properties. */
|
||||||
fun Button.enable() {
|
fun Button.enable() {
|
||||||
|
Reference in New Issue
Block a user