BACKSPACE Key When RibbonBar in AutoHide mode

3 posts, 1 answers
  1. Keith
    Keith avatar
    2 posts
    Member since:
    Jun 2013

    Posted 08 Oct 2015 Link to this post

    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. Answer
    Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 09 Oct 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Keith
    Keith avatar
    2 posts
    Member since:
    Jun 2013

    Posted 13 Oct 2015 in reply to Hristo Merdjanov Link to this post

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

    Best

    -Keith

Back to Top