HarmonyOS TextInput如何获取焦点但不弹出键盘?

如题:HarmonyOS TextInput如何获取焦点但不弹出键盘?

阅读 442
1 个回答

可构造一个宽高都为0的自定义键盘,使用customKeyboard绑定,参考示例如下:

TextInput({
  placeholder: 'wait input…',
  text: this.inputValue,
  controller: this.controller
})
  .type(InputType.PhoneNumber)
  .backgroundColor(Color.Orange)
  .width('80%')//.textAlign(TextAlign.Center)
  .onChange((value: string) => {

  })
  .customKeyboard(this.CustomKeyboardBuilderEmpty())
  .enableKeyboardOnFocus(false)
  .selectionMenuHidden(false)


@Builder
CustomKeyboardBuilderEmpty() {
  Column() {
  }
  .width(0)
  .height(0)
}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进