This is a migrated thread and some comments may be shown as answers.
Suppress home and end keys during text input
2 Answers 6 Views
This is a migrated thread and some comments may be shown as answers.
Dave Wolf
Top achievements
Rank 1
Dave Wolf asked on 19 Jan 2018, 11:51 PM
I'm trying to clear out the text entered in a RadDropdownlist while the popup is open by doing a "shift + home" to select all text but instead it causes the first dropdown item to get selected from the popup window.  Pressing the "end" key will select the last item from the list.  I've tried everything I could think of to suppress this but nothing seems to work. What can I do?

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 22 Jan 2018, 08:56 AM
Hello Dave,

The Home and End keys are handled in the DropDownPopupForm class. The following example shows how you can create a custom popup form and handle these keys:
public class MyDropDownList : RadDropDownList
{
    protected override RadDropDownListElement CreateDropDownListElement()
    {
        return new MyDropDownListElement();
    }
}
 
public class MyDropDownListElement : RadDropDownListElement
{
    protected override RadPopupControlBase CreatePopupForm()
    {
        MyPopupForm form = new MyPopupForm(this);
        this.Popup = form;
       
        this.WirePopupFormEvents(this.Popup);
 
        return form;
    }
 
   
 
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadDropDownListElement);
        }
    }
}
 
public class MyPopupForm : DropDownPopupForm
{
    public MyPopupForm(RadDropDownListElement ownerDropDownListElement)
        : base(ownerDropDownListElement)
    {
    }
 
    public override bool OnKeyDown(Keys keyData)
    {
        if ((keyData == Keys.Home || keyData == Keys.End))
        {
            return false;
        }
        return base.OnKeyDown(keyData);
    }
 
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dave Wolf
Top achievements
Rank 1
answered on 22 Jan 2018, 05:37 PM

Thank you, that's exactly what I was looking for. 

 

Asked by
Dave Wolf
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Dave Wolf
Top achievements
Rank 1
Share this question
or