当前位置:网站首页>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, 就是输入完成点击回车要做的事情。
非常的人性化。
边栏推荐
- Use of deferred environment variable in gbase 8s
- 深度学习——几种学习类型
- leetcode1221. 分割平衡字符串
- Code scanning payment flow chart of Alipay payment function developed by PHP
- STM32的DMA双缓冲模式详解
- Data import and export for gbase 8s
- Le chemin de l'apprentissage immutable - - Adieu à la copie traditionnelle
- Record small knowledge points
- Office macro virus bounce shell experiment
- GbASE 8s中的Blob 页(Blobspace page)
猜你喜欢

PHP extracts and analyzes table contents, and collects bidding information

Simple text analysis of malicious samples - Introduction

js的sort()函数

UCLA | generative pre training for black box optimization

Gbase 8s index b+ tree

Musk released humanoid robot. Why is AI significant to musk?

GBASE 8s 索引B+树

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

js中的concat()

CTF_ Web:8-bit controllable character getshell
随机推荐
Anaconda安装+TensorFlow安装+Keras安装+numpy安装(包含镜像和版本信息兼容问题)
GBASE 8s的多线程结构
Introduction to intstream API
CTF_ Web: file contains pseudo protocol with PHP
JS call() and apply()
GBASE 8s的数据视图
Upgrade PHP to php7 X (III) failure of wechat payment callback
cnpm : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。
什么是存储引擎以及MySQL常见的三种数据库存储引擎
Gbase 8s parallel operation problem scenario description
UCLA | generative pre training for black box optimization
Multithreading structure of gbase 8s
CTF_ Web:8-bit controllable character getshell
Vscode 设置clang-format
为什么TCP握手刚刚好是3次呢?
GBASE 8s 索引B+树
Unity Quad culls shaders with back faces and transparent parts
论文笔记: 多标签学习 ESMC (没看懂, 还没写出来, 暂时放这里占个位置)
2021.8.29 notes: register, bit operation, pointer, structure
ROS2/DDS/QoS/主题的记录