How can I return focus to the text editor? #330
-
|
I’m writing a package which steals focus from the text editor. For example you highlight some text and click or a toolbar button or respond to a dialog. The problem is that the highlight text is still highlighted, which is good, but the text editor has lost its focus. Is there a way of programatically setting the focus back to the editor pane? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
If you know which editor you want to focus: find its pane, then call |
Beta Was this translation helpful? Give feedback.
-
|
And now my final word on this issue. Well, a few words, really. I’m getting surprising behaviour with
Fortunately, I have discovered a solution, and I’m embarrassed that it’s taken be so long: let button = document.create('button');
button.onclick = event => {
// etc tec blah blah
atom.workspace.element.focus();
};I tried focusing on everything else, but I somehow missed that one. It all works now. |
Beta Was this translation helpful? Give feedback.
And now my final word on this issue. Well, a few words, really.
I’m getting surprising behaviour with
buttonandspanelements in the panel. I don’t know whether it’s because of the older version of Chromium or because a panel isn’t a genuine HTML element.The
buttondoesn’t appear to propagate itsclickto its container. That’s why I can’t get it to focus back on the document that way. On the other hand,spandoes propagate.This is not the behaviour if I try this in an ordinary element on a web page.
I can’t get the
spanelement to respond to thedragstartevent, even if it setdraggabletotrue. Buttons, on the other hand drag as expected once I setdraggabletotrue. It’s just as …