SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

TextEditor: Just want to show the cursor, is that too much to ask?

Last post 07-06-2009 4:44 PM by GoldenVoid. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 07-03-2009 1:38 PM

    TextEditor: Just want to show the cursor, is that too much to ask?

     HI,

    I have a TextEditor control sitting beside a Treeview. The latter holds a map of areas of the text currently shown in theTextEditor. When the Treeview map is left-clicked, I move the cursor position in the Text Editor to a specific line in the Text depending on which Treeview node was clicked. This all works fine except that the cursor disappears from the TextEditor's text pane as soon as it loses focus and I can't get it to show. The text scrolls to the new current line just fine, but there is no cursor. I have tried various things inclusing giving focus back to theTextEditor after handling theTreeview click, as follows:

    within the event-handler for the click on Treeview node is the following code...

    textEditor.ActiveTextArea.TextArea.Caret.Line = <new line number>;

    textEditor.ActiveTextArea.TextArea.Caret.Column = 0;

    textEditor.ActiveTextArea.TextArea.Focus();

    I've also tried calling the Focus() method on textEditor itself, and on ActivateTextArea, still no cursor will appear. I've also tried calling Refresh() for each control too, but I simply cannot get the TextEditor to show the current cursor unless I click within its active text, and that click is moving the cursor away from where I've carefully placed it, which is not what I want.

    Please help.

  • 07-04-2009 8:35 PM In reply to

    Re: TextEditor: Just want to show the cursor, is that too much to ask?

    If you are not using one of the double click events then you cannot set focus to any other control just by calling Focus on that control.

    Try the following code to set the focus to the text editor control:

            void TreeView1NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
            {
                BeginInvoke(new MethodInvoker(FocusTextEditor));
            }

            void FocusTextEditor()
            {
                textEditorControl.ActiveTextAreaControl.TextArea.Focus();
            }

  • 07-06-2009 4:44 PM In reply to

    Re: TextEditor: Just want to show the cursor, is that too much to ask?

     Worked like a dream, though I admit I can't see why.

    Thanks

Page 1 of 1 (3 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.