Closed Srimathi622 closed 7 months ago
@Srimathi622 When you click the button, the code editor loses focus and the cursor disappears. All you need to do is use CodeEditorTapRegion
to wrap your button. In the latest commit, I set the CodeEditorTapRegion
to public, so you can use it directly. If you use a previous version, you can refer to the implementation of CodeEditorTapRegion
.
Thank you for your response. I used the provided code to wrap the button. The editor now has focus, but the cursor is consistently positioned at the beginning of the line. My intention is to focus the cursor at the current position. Here's the code I used:
class CodeEditorTapRegion extends TapRegion {
const CodeEditorTapRegion({
required super.child,
super.onTapOutside,
}) : super(groupId: CodeEditor);
}
Thanks Srimathi
@Srimathi622 I think you can use selection
field of CodeLineEditingController
to control your cursor position.
I tried the below code, but it is only selecting the text. The cursor is not moved to the current place. For example, I am in line 12, I want to focus my cursor point in the same place after clicking the button. codeLineEditingController .selection = CodeLineSelection( baseIndex: 10, baseOffset: 10)
As I said before, you should use CodeEditorTapRegion
to keep your editor focus.
I will close this issue as completed.
Hi, I am using codeLineEditingController.text to set and get the text on the editor. I want to blink the cursor at the end of the line or document. How can I achieve this? I tried the below code while clicking the button. The cursor is not moving to the end. please help me.
setState(() { codeLineEditingController.text = formatted text;
codeLineEditingController .moveCursorToLineEnd(); });
Thanks in advance Srimathi