HarmonyOS 自定义键盘

请问有自定义键盘相关的文档或者demo吗?textInput如何关联自定义键盘。

HarmonyOS
2024-10-22 11:25:00
1184浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
put_get

自定义输入法文档参考链接:

https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/inputmethod_application_guide-V5

textInput关联自定义键盘可以使用.customKeyboard()绑定自定义键盘请参考demo

// xxx.ets

@Entry  
@Component  
struct TextInputExample {  
  controller: TextInputController = new TextInputController()  
  @State inputValue: string = ""  
  
  // 自定义键盘组件  
  @Builder CustomKeyboardBuilder() {  
    Column() {  
      Button('x').onClick(() => {  
        // 关闭自定义键盘  
        this.controller.stopEditing()  
      })  
      Grid() {  
        ForEach([1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#'], (item:number| string) => {  
          GridItem() {  
            Button(item + "")  
              .width(110).onClick(() => {  
              this.inputValue += item  
            })  
          }  
        })  
      }.maxCount(3).columnsGap(10).rowsGap(10).padding(5)  
    }.backgroundColor(Color.Gray)  
  }  
  
  build() {  
    Column() {  
      TextInput({ controller: this.controller, text: this.inputValue })  
        // 绑定自定义键盘  
        .customKeyboard(this.CustomKeyboardBuilder()).margin(10).border({ width: 1 }).height('48vp')  
    }  
  }  
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
分享
微博
QQ
微信
回复
2024-10-22 17:33:34
相关问题
HarmonyOS TextInput自定义键盘
1289浏览 • 1回复 待解决
小程序示例自定义键盘
1064浏览 • 1回复 待解决
HarmonyOS TextInput自定义键盘问题
1552浏览 • 1回复 待解决
HarmonyOS 键盘顶部添加自定义组件
941浏览 • 1回复 待解决
HarmonyOS 数字自定义键盘如何实现
1224浏览 • 1回复 待解决
HarmonyOS TextInput绑定自定义键盘问题
1347浏览 • 1回复 待解决
HarmonyOS 自定义键盘防录屏方案
755浏览 • 1回复 待解决
HarmonyOS WebView使用自定义键盘问题
864浏览 • 1回复 待解决
基于自定义键盘设置光标位置
1353浏览 • 1回复 待解决
HarmonyOS 自定义键盘不能顶起输入框
1220浏览 • 1回复 待解决
HarmonyOS 自定义键盘弹起后遮住输入框
1438浏览 • 1回复 待解决