Home Download Buy Blog Forum Support

Return focus to editor

Return focus to editor

Postby sebm on Thu Mar 29, 2012 2:56 pm

I'm writing a plugin that runs a selection of commands when menu buttons are pressed, and captures the output into the Console window (the one shown with ctrl+`).

So in my plugin:

Code: Select all
    # setup
    # ...
    # now show the panel
    self.view.window().run_command("show_panel", {"panel": "console" })
    # now run the command
    # ...
    # now return focus to the editor
    self.view.window().focus_group(0)


However, if I've got multiple Tab groups (by switching with alt+shift+2, for example) and I'm in the second pane, this always returns focus to group 0 (because that's what I've asked the function to do...)

Is there a way to make it return focus to the same one that gets focussed if I close the console (with Esc)?

Thanks!
sebm
 
Posts: 5
Joined: Sun Mar 11, 2012 4:52 pm

Re: Return focus to editor

Postby nick. on Thu Mar 29, 2012 3:01 pm

I think you'll just need to get the active view:
Code: Select all
sublime.Window.active_view
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Return focus to editor

Postby jps on Thu Mar 29, 2012 11:12 pm

window.focus_group(window.active_group()) should do what you're after
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Return focus to editor

Postby sebm on Sat Mar 31, 2012 10:26 am

That's fantastic. I'm sure I tried something like that before, but must have got the incantation slightly wrong...

Thank you!

(ps, I'm so impressed by your support jps - truly brilliant editor with a great community, and a tentative dev. Can't ask for more!)
sebm
 
Posts: 5
Joined: Sun Mar 11, 2012 4:52 pm


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 7 guests