Fix hints and outputText

This commit is contained in:
Aleksandras Kostarevas 2024-08-28 20:09:36 +03:00
parent be32a25307
commit 0c78fe5f12
3 changed files with 13 additions and 3 deletions

View File

@ -129,7 +129,7 @@ data class Key(
val hintLabel: String? = null,
/** Hint icon to display instead of hint label. Icon takes precedence over a label */
val hintIconId: String? = null,
val hintIconId: String? = if(hintLabel?.isNotEmpty() == true) { "" } else { null },
/** Flags of the label */
val labelFlags: Int,
@ -190,6 +190,14 @@ data class Key(
/** Key is enabled and responds on press */
val isEnabled: Boolean = code != Constants.CODE_UNSPECIFIED,
) {
/** Validation */
init {
assert((code == Constants.CODE_OUTPUT_TEXT && outputText != null) ||
(code != Constants.CODE_OUTPUT_TEXT && outputText == null)) {
"Output text validation failed: $code $outputText"
}
}
/** The current pressed state of this key */
private var mPressed = false

View File

@ -503,7 +503,9 @@ data class LayoutEngine(
labelFlags = data.labelFlags,
moreKeys = data.moreKeys,
moreKeysColumnAndFlags = data.moreKeyFlags,
visualStyle = data.style
visualStyle = data.style,
outputText = data.outputText,
hintLabel = data.hint.ifEmpty { null }
)
params.onAddKey(key)

View File

@ -159,7 +159,7 @@ data class EnterKey(
repeatable = false,
moreKeyFlags = moreKeyFlags,
countsToKeyCoordinate = false,
hint = "",
hint = " ",
labelFlags = 0
)
}