Alex Styl
12/08/2024, 5:53 PMBasicTextField
? Wrapping it in a DisableSelection
doesn't seem to workAlex Styl
12/09/2024, 4:38 AMenabled = false
which disabled everything (including editing and selection). Not ideal but can be used as a workaround.Halil Ozercan
12/09/2024, 11:56 AMAlex Styl
12/09/2024, 12:45 PMBasicTextField
to handy and dragging (selection) happening to it, but allow editing. This is because I want my text field to be draggablePHondogo
12/09/2024, 12:48 PMHalil Ozercan
12/09/2024, 12:49 PMvar value by remember { mutableStateOf(TextFieldValue()) }
BasicTextField(
value = value,
onValueChange = {
value = it.copy(
selection = if (it.selection.collapsed) {
it.selection
} else {
TextRange(value.selection.start)
}
)
}
)
// or
BasicTextField(rememberTextFieldState(), inputTransformation = {
if (!selection.collapsed) {
selection = TextRange(originalSelection.start)
}
})
Halil Ozercan
12/09/2024, 12:52 PMTextRange
that is used as selection. Collapsed selection means there is no selection, just a cursor. Extended is when TextRange
spans at least one character.Halil Ozercan
12/09/2024, 12:55 PMTextRange(4, 4)
is collapsed, TextRange(4, 5)
is extended.Alex Styl
12/09/2024, 3:02 PMAlex Styl
12/09/2024, 3:08 PMAlex Styl
12/20/2024, 1:46 PMBasicTextField
with a BasicText
if you need to disable editing. No other code changes neededHalil Ozercan
12/20/2024, 1:50 PMBasicTextField
and BasicText
rendering should be identical if all text related parameters are the same.Alex Styl
12/20/2024, 1:51 PMBasicTextField
has some default width for some reason. Seems like a bug which I filled it hereAlex Styl
12/20/2024, 1:52 PMDisableSelection
doesn't work on BasicTextField
Halil Ozercan
12/20/2024, 1:59 PMBasicTextField
is placed on the screen with no content in it, what should be its width? It should not be zero because then you have no way to interact with it. 1.dp
or any other similarly small value is no different than 0.dp
. Therefore we kept the initially chosen HHHHHHHHHH
as the default text that is measured for the minimum width of any BasicTextField
. IIRC the workaround you found was also the official suggestion. cc; @Grant Toepfer , I remember you looking into this.Alex Styl
12/20/2024, 2:00 PMAlex Styl
12/20/2024, 2:02 PMBasic
components as building blocks to build UI with. not to use directly in my app. that sounds like a decision for components ie for a design system.Halil Ozercan
12/20/2024, 2:03 PMBasicTextField
call should place a box on the screen that can be tapped to bring the keyboard. Otherwise expecting people to explicitly provide width modifier to achieve this behavior sounds unintuitive.Alex Styl
12/20/2024, 2:05 PMAlex Styl
12/20/2024, 2:05 PMHalil Ozercan
12/20/2024, 2:05 PMI see theI understand this point of view. You are correct thatcomponents as building blocks to build UI with. not to use directly in my app. that sounds like a decision for components ie for a design system.Basic
Basic
components are not supposed to be called directly in app code. However BasicTextField
by design has to make some tradeoffs to be at least usable. The min width is one of those. Ideally foundation would provide a modifier or some other composable that doesn't even do text layout, text selection, just text input management from InputConnection.