How to focus the Editor after insert text?
已回答
I have a function to manipulate the editor by clicking a button in a toolWindow.
But after clicking, i want to refocus the editor. Has somebody an idea?
fun manipulateForElement(editor:Editor){
val doc=editor.document
val caret=editor.caretModel.primaryCaret
val start=caret.selectionStart
val end=caret.selectionEnd
WriteCommandAction.runWriteCommandAction(editor.project) {
doc.replaceString(start, end,"test string")
}
caret.removeSelection()
caret.moveToOffset(start) // dont set the focus to the editor
}
请先登录再写评论。
Do you mean com.intellij.openapi.editor.ex.util.EditorUtil?
But this class has no method named "focusOnEditorForTyping".
Do you have an older version?
Ah, sorry about that - it is not available in the SDK. Please try with:
Thank you, its working
Thanks for sharing the solution.
UPSers
wohh, i totally agree! A useful share
geometry dash