Skip to content

Commit e42b2be

Browse files
NopoTheGamerlineargraph
authored andcommitted
add expand to fit option in text boxes
1 parent c833089 commit e42b2be

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

common/src/main/java/io/github/notenoughupdates/moulconfig/gui/component/TextFieldComponent.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ open class TextFieldComponent(
2424
private var selection = -1
2525
private var scrollOffset = 0
2626
private var visibleText: String? = null
27+
private var shouldExpandToFit = false
2728
override fun getWidth(): Int {
28-
if (isFocused) return max(preferredWidth, font.getStringWidth(text.get()) + 10)
29+
if (isFocused && shouldExpandToFit) return max(preferredWidth, font.getStringWidth(text.get()) + 10)
2930
return preferredWidth
3031
}
3132

@@ -316,6 +317,10 @@ open class TextFieldComponent(
316317
}
317318
}
318319

320+
fun setShouldExpandToFit(new: Boolean) {
321+
shouldExpandToFit = new
322+
}
323+
319324
companion object {
320325
private const val TEXT_PADDING_X = 4
321326
private const val BACKGROUND_COLOR = -0x1000000

0 commit comments

Comments
 (0)