TelerikSvgIcon events

1 Answer 27 Views
General Discussions
José Antonio
Top achievements
Rank 2
Iron
José Antonio asked on 09 Dec 2024, 10:04 AM
Unable to execute events on the TelerikSvgIcon control?
                   <FormItem Field="@nameof(User.Password)">
                       <Template>
                           <TelerikTextBox @bind-Value="@user.Password"
                                           Size="@ThemeConstants.TextBox.Size.Large"
                                           Placeholder="Contraseña"
                                           ShowSuffixSeparator="false"
                                           Password="@IsPasswordHidden">
                               <TextBoxSuffixTemplate>
                                   <TelerikSvgIcon 
                                       Icon="@SvgIcon.Eye" 
                                       Size="@ThemeConstants.SvgIcon.Size.Medium"
                                       onmousedown="@(() => MostrarPassword())"
                                       onmouseup="@(() => OcultarPassword())"
                                       onmouseleave="@(() => OcultarPassword())">
                                   </TelerikSvgIcon>
                                </TextBoxSuffixTemplate>
                           </TelerikTextBox>
                       </Template>
                   </FormItem>
Thanks

1 Answer, 1 is accepted

Sort by
0
Hristian Stefanov
Telerik team
answered on 09 Dec 2024, 01:06 PM

Hi José Antonio,

To handle events with the TelerikSvgIcon, you need to wrap it in an element that supports event handlers, such as a span or div. The TelerikSvgIcon itself does not support direct event attributes like onmousedown, onmouseup, or onmouseleave.

Solution

<FormItem Field="@nameof(User.Password)">
    <Template>
        <TelerikTextBox @bind-Value="@user.Password"
                        Size="@ThemeConstants.TextBox.Size.Large"
                        Placeholder="Contraseña"
                        ShowSuffixSeparator="false"
                        Password="@IsPasswordHidden">
            <TextBoxSuffixTemplate>
                <span style="cursor: pointer;"
                      onmousedown="@(() => MostrarPassword())"
                      onmouseup="@(() => OcultarPassword())"
                      onmouseleave="@(() => OcultarPassword())">
                    <TelerikSvgIcon Icon="@SvgIcon.Eye"
                                    Size="@ThemeConstants.SvgIcon.Size.Medium">
                    </TelerikSvgIcon>
                </span>
            </TextBoxSuffixTemplate>
        </TelerikTextBox>
    </Template>
</FormItem>

    Regards,
    Hristian Stefanov
    Progress Telerik

    Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

    Tags
    General Discussions
    Asked by
    José Antonio
    Top achievements
    Rank 2
    Iron
    Answers by
    Hristian Stefanov
    Telerik team
    Share this question
    or