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

BACKSPACE Key When RibbonBar in AutoHide mode

2 Answers 44 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 08 Oct 2015, 11:26 AM
I am using Telerik UI for Winforms Q1 2015 and I have an application that uses the RibbonBar. On one of the command tabs there is a TextBox which allows user input. When the RibbonBar is displayed the user can enter and edit text in the TextBox without issue. However, when the RibbonBar is in AutoHide mode, (i.e. it is closed but opens when the user selects a tab) ​​whenthe user enters text into the TextBox, if they hit the backspace key (to amend text, etc.) the RibbonBar closes. I have tried to trap the key and handle the deletion programmatically but, seemingly, the backspace key is monitored at a low level and I can't find a way to avoid this behaviour.

Any suggestions / fixes / guidance would be welcomed.

2 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 09 Oct 2015, 03:11 PM
Hi Keith,

Thank you for writing.

Pressing the backspace when the RadRibbonBar is not expanded would collapse it again. Indeed, if you are having a text box and you are typing in it that is not expected. In order to overcome it, you can handle the GotFocus and LostFocus event of the TextBoxItem and perform check if you can collapse the ribbon. Please check my code snippet below: 
public Form1()
{
    InitializeComponent();
 
    this.radTextBoxElement1.TextBoxItem.GotFocus += TextBoxItem_GotFocus;
    this.radTextBoxElement1.TextBoxItem.LostFocus += TextBoxItem_LostFocus;
}
 
bool expandedFlag = false;
private void TextBoxItem_GotFocus(object sender, EventArgs e)
{
    if (!this.radRibbonBar1.Expanded)
    {
       this.radRibbonBar1.Expanded = true;
        expandedFlag = true;
    }
}
 
private void TextBoxItem_LostFocus(object sender, EventArgs e)
{
    if (expandedFlag)
    {
        this.radRibbonBar1.Expanded = false;
        expandedFlag = false;
    }
}

I am also sending you a gif file with the result on my end.

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Keith
Top achievements
Rank 1
answered on 13 Oct 2015, 11:18 AM

Many thanks for your help, Hristo. It certainly gets round the problem.

Best

-Keith

Tags
RibbonBar
Asked by
Keith
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Keith
Top achievements
Rank 1
Share this question
or