How to create editor and focus on it


Now to create editor I use
inField = document.createElement(‘atom-text-editor’)
inField.setAttribute(‘mini’, ‘’)
editor = inField.getModel()
Is there better way to do it?

And I want to create function which will make editor focused
doesn’t work because editor doesn’t have own pane



I am guessing what you are looking for is:
(click to view)

Executing the command without parameters will open an empty editor and settle focus on it. Else the parameters can tell it what to open, in which pane, and where to focus the cursor.

Is that what you are looking for? Perhaps something else…?


That’s not what I need. I have a pane with several elements, one of which is mini editor. I want it to become focused when user activates this pane. I know, how to make it

  atom.workspace.onDidChangeActivePaneItem( (item) ->
    if item is myItem
      # I need to write here something to focus on editor

My pane looks like

  <div> ... </div>


From my understanding the open command should be able to focus on an already created item.
…not sure if it applies to ‘mini’ or if the command actually does as advertised.

Okay… Perhaps the following project will be of more interest:
Focus fix 3 (#276)
Focus on the mentioned issue and see if there are some ideas that are helpful.


Thank you, it was very useful.

Actually, I found how to focus on editor



Thanks for the feedback.
…more so for sharing the solution.

TAGS: coding for atom in atom, focus loss, focus, pane, workspace, open editor, mini, coffeescript