当前位置:网站首页>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, 就是输入完成点击回车要做的事情。
非常的人性化。
边栏推荐
- Solution of gbase 8s livelock and deadlock
- GBASE 8s的隔离级别介绍
- CTF_ Web: Advanced questions of attack and defense world expert zone WP (15-18)
- 记录小知识点
- js的sort()函数
- A detailed summary of four handshakes (or four waves) over TCP connections
- 为什么TCP握手刚刚好是3次呢?
- Use of deferred environment variable in gbase 8s
- 冰冰学习笔记:循环队列的实现
- Part I Verilog quick start
猜你喜欢

Vscode 设置clang-format

单元测试覆盖率

What is the storage engine and the three common database storage engines for MySQL

Deep learning - several types of learning

重磅直播 | 相移法+多频外差之数学原理推导+实现

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

Record the problem of C # print size once

《牛客刷verilog》Part I Verilog快速入门

LabVIEW开发气体调节器

Concat() in JS
随机推荐
CTF_ Web:php weak type bypass and MD5 collision
CTF_ Web: Advanced questions of attack and defense world expert zone WP (19-21)
The consciousness of a programmer
Bingbing's learning notes: implementation of circular queue
CTF_ Web: deserialization of learning notes (II) CTF classic test questions from shallow to deep
GBASE 8s 索引R树
Simple text analysis of malicious samples - Introduction
Excel exports data to SQL and pictures to folder through macro | VBA
分布式websocket搭建方案
Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)
A detailed summary of four handshakes (or four waves) over TCP connections
ROS2/DDS/QoS/主题的记录
JS' sort() function
Upgrade PHP to php7 X (III) failure of wechat payment callback
LabVIEW development gas regulator
CMD operation MySQL in Windows
GBASE 8s存储过程语法结构
计算学生成绩等级(虚函数和多态)
华为鸿蒙开发第四课
Gbase 8s index b+ tree