How to place icon next to or within input field

前端 未结 3 754
滥情空心
滥情空心 2020-12-20 03:14

How I can put my icon next to or within the input field?

The problem is, the icon changes the form. Usually, it\'s like this:

But when I\'m adding the icon

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-20 04:05

    Update: with the change in commit:8f1757d, which is available since UI5 1.84, the value help icon can be changed via valueHelpIconSrc:

    
    

    No need to extend sap.m.InputBase in this case. Other input controls like sap.m.MaskInput still need to be extended as shown below.


    Original answer:

    The best solution is like the Datum above with a small icon inside where I can click. (...) Is it possible?

    Yes, it's possible. Here is a minimal example: https://embed.plnkr.co/EzlF2tkvalJWvSEn

    For this, UI5 provides the API addEndIconapi which is protected, meaning it should be used only when extending sap.m.InputBase!

    As an argument for the addEndIcon, you can pass a map of settings that are required to create sap.ui.core.Iconapi, which is highly customizable.

    const icon = this.addEndIcon({
      id: this.getId() + "-questionMarkBtn",
      src: IconPool.getIconURI("sys-help"),
      noTabStop: true,
      tooltip: "Information",
      press: this.onEndButtonPress.bind(this),
    }); // See sap.ui.core.Icon/properties for more settings
    // icon.addStyleClass(...); if even more customization required..
    

提交回复
热议问题