HarmonyOS TextArea如何在enterKeyType为send的情况下,点击发送不收起键盘

HarmonyOS
2024-12-25 08:15:37
648浏览
收藏 0
回答 1
回答 1
按赞同
/
按时间
shlp

建议先使用RichEditor来开发。RichEditor可以由开发者控制点击发送以后是否收起键盘。如下:

https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/ts-basic-components-richeditor-V5#submitcallback12

使用RichEditor,参考demo:

@Entry
@Component
struct Index {
  controller: RichEditorController = new RichEditorController();
  options: RichEditorOptions = { controller: this.controller };

  build() {
    Row() {
      Column() {
        RichEditor(this.options)
          .onReady(() => {
            this.controller.addTextSpan("@地球 ",
              {
                style:
                {
                  fontColor: '#007dff',
                  fontSize: 16
                }
              })
          })
          .onIMEInputComplete((value: RichEditorTextSpanResult) => {
            console.log(`reulst ==> ${JSON.stringify(value)}`);
          })
          .enterKeyType(EnterKeyType.Send)
          .borderWidth(1)
          .borderColor(Color.White)
          .backgroundColor(Color.White)
          .width("100%")
          .onSubmit((enterKey: EnterKeyType, event: SubmitEvent) => {
            // 调用时保持编辑态。
            event.keepEditableState();
          })
      }
      .width("100%")
    }
    .height("100%")
    .backgroundColor('#ffeeeeee')
  }
}
  • 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.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
分享
微博
QQ
微信
回复
2024-12-25 11:00:15


相关问题
HarmonyOS 键盘如何不收起
704浏览 • 1回复 待解决
如何在多设备情况下使用hdc
1971浏览 • 2回复 待解决
HarmonyOS如何收起键盘
842浏览 • 1回复 待解决
HarmonyOS 手机静音情况下,无法震动
953浏览 • 1回复 待解决
HarmonyOS 键盘收起
519浏览 • 1回复 待解决