This is a migrated thread and some comments may be shown as answers.

RadMaskedTextInput: completely remove/hide Context Menu

4 Answers 40 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arsen
Top achievements
Rank 1
Veteran
Arsen asked on 12 Nov 2020, 10:47 AM

Hi,

How can I completely remove or hide Context Menu (aka Copy/Past menu) appearing when I'm right-clicking on the `telerik:RadMaskedTextInput`?


4 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 17 Nov 2020, 10:03 AM

Hello Arsen,

The context menu that appears when you right click on the masked input control is the default one that comes with the native TextBox element. In order to prevent it from displaying you can use the TextBoxStyle property of the masked input controls. Here is an example:

<telerik:RadMaskedTextInput>
    <telerik:RadMaskedTextInput.TextBoxStyle>
       <Style TargetType="TextBox">
           <Setter Property="ContextMenuService.ContextMenu">
               <Setter.Value>
                   <ContextMenu Width="0" Height="0" />
               </Setter.Value>
           </Setter>
           <Setter Property="BorderThickness" Value="0" />           
        </Style>
    </telerik:RadRadMaskedCurrencyInput.TextBoxStyle>
</telerik:RadMaskedCurrencyInput>

Can you try this and let me know how it goes?

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Arsen
Top achievements
Rank 1
Veteran
answered on 25 Nov 2020, 08:36 AM

This works, thank you!

However, it is also overriding the default styles (textbox) of the application and particularly for my case it's making the mouse left click not working.

I was able to fix the problem by putting :

BasedOn="{StaticResource {x:Type TextBox}}"

 

However this doesn't fix the problem completely, particularly our styles for RadMaskedInput are based on RadMaskedInputBaseStyle

and now when focusing on the textbox I can see a white background.

 

Is there any other workaround instead of putting Height and Width to 0?

To be honest for me, this is not the best option.

0
Arsen
Top achievements
Rank 1
Veteran
answered on 25 Nov 2020, 10:10 AM

I was able to fix the problem by pointing to PreviewInputTextbox type instead of TextBox:

<telerik:RadMaskedTextInput.TextBoxStyle>
        <Style TargetType="{x:Type maskedInput:PreviewInputTextBox}"
               BasedOn="{StaticResource MaskedInputTextBoxStyle}">
            <Setter Property="ContextMenuService.ContextMenu">
                <Setter.Value>
                    <ContextMenu Visibility="Collapsed"/>
                </Setter.Value>
            </Setter>
        </Style>
</telerik:RadMaskedTextInput.TextBoxStyle>

 

Please note that using Visibility="Collapsed" is a better alternative of putting element Height and Width to 0 because in the last case, the element still exists in the UI, but just with no dimensions, which is itself error-prone.

0
Martin Ivanov
Telerik team
answered on 27 Nov 2020, 08:44 AM

Hello Arsen,

Thank you for sharing your solution. Indeed, PreviewInputTextbox is the more appropriate TargetType for the style.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Arsen
Top achievements
Rank 1
Veteran
Answers by
Martin Ivanov
Telerik team
Arsen
Top achievements
Rank 1
Veteran
Share this question
or