当前位置:网站首页>Kotlin Compose 监听软键盘 点击enter提交事件
Kotlin Compose 监听软键盘 点击enter提交事件
2022-06-25 04:01:00 【安果移不动】
@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,
//配置软键盘
keyboardOptions = KeyboardOptions.Default.copy(imeAction = ImeAction.Done),
keyboardActions = KeyboardActions(onDone = {
onImeAction()
//点击完成之后 隐藏键盘
keyboardController?.hide()
})
)
}

使用这个controller
LocalSoftwareKeyboardController
单是这个和Flutter不同。不用设置到实际的控件当中
onImeAction: () -> Unit, 就是输入完成点击回车要做的事情。
非常的人性化。
边栏推荐
- Value transfer between parent and child components of wechat applet
- Concat() in JS
- [untitled]
- Upgrade PHP to php7 X (III) failure of wechat payment callback
- i. Max development board learning record
- Paper notes: multi label learning ESMC (I don't understand it, but I haven't written it yet, so I'll put it here for a place temporarily)
- CTF_ Web: basic 12 questions WP of attack and defense world novice zone
- JS call() and apply()
- 微信小程序父子组件之间传值
- Structure syntaxique des procédures stockées gbase 8S
猜你喜欢
随机推荐
GBASE 8s的数据导入和导出
Data view for gbase 8s
Anaconda installation +tensorflow installation +keras installation +numpy installation (including image and version information compatibility issues)
Mongodb cluster
领导:谁再用 Redis 过期监听实现关闭订单,立马滚蛋!
GBASE 8s存儲過程語法結構
halcon之区域:多种区域(Region)生成(3)
Classification of gbase 8s locks
Record of the 25th week
515. find the maximum value / Sword finger offer II 095 in each tree row Longest common subsequence
Bingbing's learning notes: implementation of circular queue
CTF_ Web: Advanced questions of attack and defense world expert zone WP (9-14)
Gbase 8s overall architecture
Wechat likes to pay attention to the solution of invalid automatic reply
Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)
2.0SpingMVC使用RESTful
彻底理解数据库事务
GBASE 8s存储过程语法结构
计算学生成绩等级(虚函数和多态)
OOP 向量加减(友元+拷贝构造)









