当前位置:网站首页>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, 就是输入完成点击回车要做的事情。
非常的人性化。
边栏推荐
- Record of the 25th week
- Gbase 8s stored procedure execution and deletion
- CTF_ Web: how to recognize and evaluate a regular expression
- Value transfer between parent and child components of wechat applet
- OOP栈类模板(模板+DS)
- 2.0springmvc uses restful
- SQL injection details
- GBASE 8s存储过程流程控制
- CTF_ Web: Learn flask template injection (SSTI) from 0
- LabVIEW开发气体调节器
猜你喜欢

JS arguments

记录小知识点

Unity Quad culls shaders with back faces and transparent parts

30岁了开始自学编程,家里比较困难还来得及吗?

File upload vulnerability shooting range upload labs learning (pass1-pass5)

CTF_ Web: basic 12 questions WP of attack and defense world novice zone

cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。

The solution of wechat applet switchtab unable to take parameters

Deep learning - several types of learning

Upgrade PHP to php7 The impact of X (I). The problem of session retention. Keep login
随机推荐
GBASE 8s的并行操作问题场景描述
GBASE 8s的数据视图
2.0springmvc uses restful
JS call() and apply()
Upgrade PHP to php7 X (III) failure of wechat payment callback
什么是持久化?redis 持久化中的RDB和AOF是什么?
GBASE 8s的触发器
How to screen out words related to products and eliminate invalid words accurately
Solution of gbase 8s livelock and deadlock
Gbase 8s stored procedure syntax structure
Upgrade PHP to php7 The impact of X (I). The problem of session retention. Keep login
Retrofit 源码分析
i. Max development board learning record
Gbase 8s stored procedure flow control
GBASE 8s 索引R树
坐标系左乘右乘
论文笔记: 多标签学习 ESMC (没看懂, 还没写出来, 暂时放这里占个位置)
CTF_ Web: Changan cup-2021 old but a little new & asuka
彻底理解数据库事务
「 每日一练,快乐水题 」1108. IP 地址无效化