当前位置:网站首页>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 .
边栏推荐
- ASEMI三相整流桥的工作原理
- Kotlin Compose 监听软键盘 点击enter提交事件
- WPF 使用 MAUI 的自绘制逻辑
- Wechat likes to pay attention to the solution of invalid automatic reply
- 电脑的dwg文件怎么打开
- js中的concat()
- 成功解决:selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from
- Coordinate system left multiply right multiply
- 为什么SQL语句命中索引比不命中索引要快?
- XML (VIII)
猜你喜欢

冰冰学习笔记:循环队列的实现

Machine learning deep learning -- Vectorization

Record the problem of C # print size once

ASEMI三相整流桥的工作原理

【图像融合】基于matlab方向离散余弦变换和主成分分析图像融合【含Matlab源码 1907期】

【FLink】access closed classloader classloader.check-leaked-classloader

机器学习深度学习——向量化

我的IC之旅——资深芯片设计验证工程师成长——“胡”说IC工程师完美进阶

CTF_ Web: Advanced questions of attack and defense world expert zone WP (15-18)

Records of ros2/dds/qos/ topics
随机推荐
Blob page in gbase 8s
Write shell script error summary
Upgrade PHP to php7 The impact of X (I). The problem of session retention. Keep login
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
Immutable学习之路----告别传统拷贝
写shell脚本报错总结
How to apply for software
JS call() and apply()
dotnet-exec 0.4.0 released
大话云原生数据库中的存算分离
js的sort()函数
Le chemin de l'apprentissage immutable - - Adieu à la copie traditionnelle
固态硬盘开盘数据恢复的方法
Vscode 设置clang-format
DMA double buffer mode of stm32
Unity Quad culls shaders with back faces and transparent parts
"Daily practice, happy water" 1108 IP address invalidation
Triangle class (construction and deconstruction)
绝了!自动点赞,我用 PyAutoGUI!
Chapter IX app project test (2) test tools