RadRichTextBox gets focus but does not display cursor and typing has no effect.

4 posts, 1 answers
  1. Michael
    Michael avatar
    15 posts
    Member since:
    Sep 2010

    Posted 29 Sep 2010 Link to this post

    I'm using a radrichtextbox with the radrichtextboxribbonui in a grid.  Above it I have a RadMenu with a "format" submenu.  When it loses focus, I call

    private void ReturnLastFocus(object sender, Telerik.Windows.RadRoutedEventArgs e)
            {
                    _myRTB.Focus();
                    _myRTB.UpdateEditorLayout();
            }
     
    I've tried creating a new method called when myRTB.GotFocus and placing '_myRTB.UpdateEditorLayout();' in there and it made no difference.  
    My bold function works for whatever is selected, the focus is set to _myRTB, but for whatever reason the cursor doesn't display, and input from the keyboard is ignored.
    Any ideas?
  2. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 30 Sep 2010 Link to this post

    Hello Michael,

    There was an issue related to RadRichTextBox.Focus() method that we resolved in Q2.SP2 release.
    Here is a workaround for the previous versions (Q2.SP1 and earlier):
    ((DocumentPresenterBase)this.radRichTextBox1.ActiveEditorPresenter).FocusCaret();

    With SP2 version the cursor should appear on the position it was last as soon as your RadRichTextBox receives the focus . You set the focus as simple as this:
    this._myRTB.Focus();

    If the cursor does not appear where it last was, then you are probably using an older version of our controls and you have to manually set the position of the cursor, as shown below:
    Telerik.Windows.Documents.Model.PointF location = this._myRTB.Document.CaretPosition.Location;
    this._myRTB.Document.CaretPosition.SetPosition(location);

    Let us know whether this helps.
     
    Regards,
    Iva
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Michael
    Michael avatar
    15 posts
    Member since:
    Sep 2010

    Posted 30 Sep 2010 Link to this post

    This worked perfectly, but I think an update would be my better option.
    Thanks for your help.
  4. Marc
    Marc avatar
    4 posts
    Member since:
    Jun 2016

    Posted 16 Jun in reply to Iva Toteva Link to this post

    I just ran into this problem again today.  I was calling:

    radRichTextBox.Focus();

    and the focus was not going into the radRichTextBox and the caret was not being displayed.

    I replaced it with a call to:

    ((DocumentPresenterBase)radRichTextBox.ActiveEditorPresenter).FocusCaret();

    And everything is working fine.

    I am using v2017.2.503 of the Telerik libraries (I think that is Q2 2017).

  5. Marc
    Marc avatar
    4 posts
    Member since:
    Jun 2016

    Posted 16 Jun in reply to Marc Link to this post

    Sorry to necro this thread.

    I had thought the change I made above fixed the problem I was seeing.  It did not.  I need to look further into the problem I am seeing.

Back to Top