JunoLab / atom-ink

IDE toolkit for Atom
MIT License
229 stars 40 forks source link

HELP: focusInput when console pane activates #15

Closed sglyon closed 9 years ago

sglyon commented 9 years ago

I'm trying to figure out how to focus on the input line whenever the pane holding the console becomes active.

To do this I modified openInTab to register a callback with the new pane it creates. This callback should call the focusInput method on the view whenever the pane becomes active.

I modified focusInput to have it log when the function is called, and when it properly finds the last atom-text-editor.

From the console log it seems like the function is being called whenever the pane becomes active, but I still can't focus on the input line.

Any suggestions? When we figure this out we will just wipe these commits and start a fresh PR.

pfitzseb commented 9 years ago

Hm. Your changes do work for me, I think -- when focusing on the console pane the last input line is focused automatically (though I gotta admit I just typed the changes in instead of using your fork). I really like this change, btw!

sglyon commented 9 years ago

Oh that's great.

How are you switching to the REPL pane?

pfitzseb commented 9 years ago

Just clicking on the Console tab or the pane does the trick. Haven't tried the shortcuts yet. Shortcuts don't work. I think this is more of a problem with Atom than with your code though.

sglyon commented 9 years ago

Yeah, so clicking the mouse should have already been working from these lines.

What I'm going for here is auto focus on input line when I move to the REPL pane via keyboard shortcuts.

I can't get that to work

pfitzseb commented 9 years ago

Those lines wouldn't focus the editor when clicking on the pane though, right? And it doesn't work without your fix, so I think it does something ;)

sglyon commented 9 years ago

Nice, well glad it is doing something.

If you have any ideas about how to get it to work when using keyboard shortcuts I'm open to suggestions.

sglyon commented 9 years ago

Nice, that worked!

I have rebased and left only the commit that wraps in setTimeout

MikeInnes commented 9 years ago

Awesome, glad to have the patch!

sglyon commented 9 years ago

Just a heads up

So this trick only works when we keep the REPL in the pane we create for it.

If we move the REPL to a different pane (e.g. next to the editor, instead of below it), the onDidActivate callback we rely on here doesn't apply to the new pane and we don't get auto-focus on input line when moving to the pane with the REPL