Problems with shortcuts in RadRichTextbox

9 posts, 1 answers
  1. Lukasz
    Lukasz avatar
    3 posts
    Member since:
    Jul 2012

    Posted 13 Jul 2012 Link to this post

    Hi.

    I'm a little new in telerik controls, but i have a problem with RichTextbox. When I try to type letter 'ą', which is combination of keys Alt + a, the text in control is selected but I have not the letter 'ą' in my control. Is there any possible to disable shortcuts in RichTextBox ?
    Thanks for the response.
    Best regards
    Lukasz
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 18 Jul 2012 Link to this post

    Hi Lukasz,

    Before I assist you, I would like know how I can enable such a keyboard layout on Windows installation? Do I need to install additional software?

    Regards,
    Svett
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lukasz
    Lukasz avatar
    3 posts
    Member since:
    Jul 2012

    Posted 18 Jul 2012 Link to this post

    Hi Svett,

    I think no. You must enter in Control Panel -> Clock, Language, and Region -> Change keybords or other input methods. Then, in window "Region and Language", you must select "Keyoards and Languages" page and after that click in "Change keyboards..." button. In section "Installed services" click button "Add..". Next select from this long tree node "Polish" and after expand under "Keyboard" check Polish (Programmers). Uff... a little long ;-)

    To enter letter "ą" you must press right Alt key and letter a. Its looks like shortcuts (select, copy)working with Ctrl key and right Alt key.

    Best regards
    Lukasz
  5. Answer
    Svett
    Admin
    Svett avatar
    728 posts

    Posted 20 Jul 2012 Link to this post

    Hello Lukasz,

    Thank you for detailed illustration. I managed to reproduce your scenario. This happens because of default input logic of RadRichTextBox. You can achieve the desired scenario by creating custom input behavior:
    public class RichTextBoxInputBehavior : InputBehavior
    {
        public RichTextBoxInputBehavior(DocumentView view)
            : base(view)
        {
     
        }
     
        protected override void PerformSelectAllOperation(KeyEventArgs e)
        {
     
        }
    }

    Then you should replace the default one:
    this.richTextBox.DocumentView.InputBehavior = new RichTextBoxInputBehavior(this.richTextBox.DocumentView);

    I hope this helps.

    Kind regards,
    Svett
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  6. Lukasz
    Lukasz avatar
    3 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2012 Link to this post

    Hi Svett,

    Yours solution is working very well. Thank You. Here is full implementation for other Polish people ;-)
    public class RichTextBoxInputBehavior : InputBehavior
       {
           public RichTextBoxInputBehavior(DocumentView view)
               : base(view)
           {
     
           }
     
           protected override void PerformSelectAllOperation(KeyEventArgs e)
           {
               if (!e.Alt)
               {
                   base.PerformSelectAllOperation(e);
               }
     
           }
     
           protected override void PerformCopyOperation(KeyEventArgs e)
           {
               if (!e.Alt)
               {
                   base.PerformCopyOperation(e);
               }
           }
     
           protected override void PerformUndoOperation(KeyEventArgs e)
           {
               if (!e.Alt)
               {
                   base.PerformUndoOperation(e);
               }
           }
     
           protected override void PerformCutOperation(KeyEventArgs e)
           {
               if (!e.Alt)
               {
                   base.PerformCutOperation(e);
               }
           }
     
           protected override void PerformAlignmentOperation(KeyEventArgs e)
           {
               if (!e.Alt)
               {
                   base.PerformAlignmentOperation(e);
               }
           }
       }

    Once more - Big Thanks ;-)
    Greetings
    Lukasz
  7. Paweł
    Paweł avatar
    2 posts
    Member since:
    Oct 2014

    Posted 06 Oct 2014 in reply to Lukasz Link to this post

    Hi,
    in WinForm with RadRichTextBox and Polish Programmer keyboard, when I use shortcuts:
    alt+e -> expect 'ę' but I get '€ę'
    alt+c -> expect 'ć' but I get '©ć'.
    I don't need this extra ALT shortcuts like alt+t -> '™'.
    I use only in editor shortcuts with control like CTRL+B to bold text.
  8. Tomasz
    Tomasz avatar
    1 posts
    Member since:
    May 2013

    Posted 08 Oct 2014 Link to this post

    I have the same problem with alt+e and alt+c.
    Please help.
  9. George
    Admin
    George avatar
    500 posts

    Posted 09 Oct 2014 Link to this post

    Hello guys,

    Thank you for reaching out to us.

    In the same InputBehavior which Lukasz provided, you can override the ProcessKeyDownCore method as follows:
    public class RichTextBoxInputBehavior : InputBehavior
    {
        public RichTextBoxInputBehavior(DocumentView view)
            : base(view)
        {
     
        }
     
        protected override void PerformSelectAllOperation(KeyEventArgs e)
        {
            if (!e.Alt)
            {
                base.PerformSelectAllOperation(e);
            }
     
        }
     
        protected override void PerformCopyOperation(KeyEventArgs e)
        {
            if (!e.Alt)
            {
                base.PerformCopyOperation(e);
            }
        }
     
        protected override void PerformUndoOperation(KeyEventArgs e)
        {
            if (!e.Alt)
            {
                base.PerformUndoOperation(e);
            }
        }
     
        protected override void PerformCutOperation(KeyEventArgs e)
        {
            if (!e.Alt)
            {
                base.PerformCutOperation(e);
            }
        }
     
        protected override void PerformAlignmentOperation(KeyEventArgs e)
        {
            if (!e.Alt)
            {
                base.PerformAlignmentOperation(e);
            }
        }
     
        protected override bool ProcessKeyDownCore(KeyEventArgs e)
        {
            if (e.Control && e.Alt)
            {
                switch (e.KeyCode)
                {
                    case Keys.E:
                    case Keys.R:
                    case Keys.T:
                    case Keys.C:
                        return false;
                }
            }
     
            return base.ProcessKeyDownCore(e);
        }
    }

    Further below, my colleague Svetlin has provided the code needed to register the behavior.

    Let me know, should you have further questions.

    Regards,
    George
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  10. Paweł
    Paweł avatar
    2 posts
    Member since:
    Oct 2014

    Posted 09 Oct 2014 Link to this post

    It work.
    Thank's for solution.
Back to Top
UI for WinForms is Visual Studio 2017 Ready