当前位置:网站首页>Kotlin compose listens to the soft keyboard and clicks enter to submit the event
Kotlin compose listens to the soft keyboard and clicks enter to submit the event
2022-06-25 04:47:00 【Ango cannot move】
@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun TodoInputText(
text: String,
onTextChanged: (String) -> Unit,
onImeAction: () -> Unit,
modifier: Modifier = Modifier,
) {
val keyboardController = LocalSoftwareKeyboardController.current
TextField(
value = text,
onValueChange = onTextChanged,
modifier = modifier,
colors = TextFieldDefaults.textFieldColors(backgroundColor = Color.Transparent),
maxLines = 1,
// Configure soft keyboard
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {
onImeAction()
// Click finish Hidden keyboard
keyboardController?.hide()
})
)
}

Use this controller
LocalSoftwareKeyboardController
Just this and Flutter Different . No need to set it to the actual control
onImeAction: () -> Unit, It is to input the things to be done by clicking "enter" .
Very human .
边栏推荐
- 第九章 APP项目测试(2) 测试工具
- Immutable學習之路----告別傳統拷貝
- Get to know the drawing component of flutter - custompaint
- OpenSea PHP开发包
- File upload vulnerability shooting range upload labs learning (pass1-pass5)
- 电脑的dwg文件怎么打开
- Structure syntaxique des procédures stockées gbase 8S
- 记录小知识点
- Solution of gbase 8s livelock and deadlock
- Record the problem of C # print size once
猜你喜欢

Deep learning - several types of learning

Upgrade PHP to php7 The impact of X (2), the obsolescence of mcrypt decryption

Vscode 设置clang-format

Region of Halcon: generation of multiple regions (3)

js中的concat()

CTF_ Web: deserialization of learning notes (II) CTF classic test questions from shallow to deep

大话云原生数据库中的存算分离
三角形类(构造与析构)

Part I Verilog quick start

MySQL concept and operation (III)
随机推荐
电脑的dwg文件怎么打开
The consciousness of a programmer
Data import and export for gbase 8s
Cascading deletion of gbase 8s
在 .NET 6 中使用 dotnet format 格式化代码
WPF 使用 MAUI 的自绘制逻辑
Mongodb cluster
Cannot import name 'escape' from 'jinja2' [solved successfully]
机器学习深度学习——向量化
CTF_ Web: deserialization learning notes (I) classes and objects in PHP
OLAP analysis engine kylin4.0
Upgrade PHP to php7 X (III) failure of wechat payment callback
[untitled]
Le chemin de l'apprentissage immutable - - Adieu à la copie traditionnelle
Web3 DApp用户体验最佳实践
2.0springmvc uses restful
js的arguments
OOP stack class template (template +ds)
Package for gbase 8s
Gbase 8s memory management