A while ago Google made "BasicTextField2" to an official overload of "BasicTextField". The main difference is that it does not organize its text value via "TextFieldValue" and the "onValueChanged" method, but with a TextFieldState.
Another change in its API was that there is no keyboardActions
parameter anymore. It was replaced by onKeyboardAction
which is a KeyboardActionHandler.
As you can see, this handler does not provide any information about the pressed IME Action. It just allows to intercept any IME action and then optionally perform the default action.
I cannot find ANY example of the usage of this interface. How would I react to ImeAction.Done or ImeAction.Next with this version of the BasicTextField?
Since you can only specify a single ImeAction in the keyboardOptions, it is unambiguous which one was triggered.
The old BasicTextFields provided separate callbacks for each ImeAction, so you needed to write something like this:
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
),
keyboardActions = KeyboardActions(onDone = { println("Done") }),
where onDone
conveys redundant information, because no other ImeAction than the one specified (i.e. ImeAction.Done
) can be triggered.
This is now optimized away with the new BasicTextField, where you can simply write this:
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Done,
),
onKeyboardAction = { println("Done") },
The triggered action will always be the one that you specified (i.e. ImeAction.Done
).