How can I handle the event when an icon added by AddIcon is clicked in SfTextBox?

Hello.

I want to do a specific action when clicking an icon added to the SfTextBox.

I know how to register a click event on SfTextrBox itself.
How do I get a specific event to fire when clicking on an icon area added via AddIcon?

Thank you.


3 Replies 1 reply marked as answer

PM Ponmani Murugaiyan Syncfusion Team August 13, 2020 09:47 AM UTC

Hi Seil,  

Greetings from Syncfusion support.  

We have validated the requested requirement and considering “Provide support for event handling on added icon using addIcon method” as a feature in our end. This support will be included in any one of our upcoming releases.    
    
You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through the below link.   
    

Regards, 
Ponmani M

Marked as answer

MI Mike January 28, 2022 01:12 AM UTC

would be a nice feature to add.   the workaround i use now is JS to move a clickable icon now (embedded in a span) into the target textbox control ... but the JS rendering is visible to the user in the browser so it appears clunky (the icon jumps around)



SP Sureshkumar P Syncfusion Team January 31, 2022 12:18 PM UTC

 
 
Code example: 
<SfTextBox @ref="@TouchIcon" Created="@onCreateTouchIcon"></SfTextBox> 
@code { 
    SfTextBox TouchIcon; 
    public async Task onCreateTouchIcon() 
    { 
        var eventdoubleClick = EventCallback.Factory.Create<MouseEventArgs>(this, iconDoubleClick); 
        var touchHover = EventCallback.Factory.Create<MouseEventArgs>(this, touchIconMouseHover); 
        var touchLeave = EventCallback.Factory.Create<MouseEventArgs>(this, touchIconLeave); 
        var touchMouseDown = EventCallback.Factory.Create<MouseEventArgs>(this, touchIconMouseDown); 
        var touchMouseUp = EventCallback.Factory.Create<MouseEventArgs>(this, touchIconMouseUp); 
        // Event creation with event handler  
        var touchStart = EventCallback.Factory.Create<TouchEventArgs>(this, touchIconStart); 
        await TouchIcon.AddIcon("prepend", "e-icon-pan", new Dictionary<string, object>() { { "ontouchstart", touchStart } }); 
        await TouchIcon.AddIcon("append", "e-date-icon", new Dictionary<string, object>() { { "ondblclick", eventdoubleClick } }); 
        await TouchIcon.AddIcon("append", "e-search-icon", new Dictionary<string, object>() { { "onmouseup", touchMouseUp } }); 
        await TouchIcon.AddIcon("prepend", "e-search-icon", new Dictionary<string, object>() { { "onmouseover", touchHover }, { "onmouseleave", touchLeave }, { "onmousedown", touchMouseDown } }); 
    } 
    public void touchIconMouseUp() 
    { 
        this.value += "Icon mouse up Event triggered \n"; 
    } 
    public void touchIconStart() 
    { 
        this.value += "Icon touch start Event triggered \n"; 
    } 
    public void iconDoubleClick() 
    { 
        this.value += "Icon double Click Event triggered \n"; 
    } 
    public void touchIconMouseHover() 
    { 
        this.value += "Icon mouse hover Event triggered \n"; 
    } 
    public void touchIconLeave() 
    { 
        this.value += "Icon mouse leave Event triggered \n"; 
    } 
    public void touchIconMouseDown() 
    { 
        this.value += "Icon mouse down Event triggered \n"; 
    } 
} 
<style> 
    .e-search-icon::before { 
        content'\e724'; 
        font-family: e-icons; 
    } 
    .e-icon-pan::before { 
        content'\e711'; 
        font-family: e-icons; 
    } 
    td{ 
        padding-left50px; 
    } 
</style> 
 
 
 
Please let us know if you need any further assistance on this.  
 
Regards, 
Sureshkumar p 


Loader.
Up arrow icon