Sublime Forum

show_overlay callback

#1

Hi,
is there a way to get called back when show_overlay is done inside of a plugin?

window = sublime.active_window()
window.run_command(“show_overlay”, {“overlay”: “goto”, “show_files”: True})

def on_show_overlay_done():
# User pressed something

Thanks,
Vjekoslav

0 Likes

#2

No, you cannot pass callables as arguments to commands.

If you describe what you want to do, we might be able to figure out a workaround however.

3 Likes

#3

I’m writing a plugin, so it’s a bit hard to explain what exactly I’m trying to achieve. I want to manipulate with newly opened views. I was considering using EventListeners functions like on_activated, but the problem is, I don’t know in what way user opened the view. Is there a quick way to make my own overlay with file names. I could feed that to window.show_quick_panel where I can register for a callback. I assume I could use standard python to walk project directory, but that seems to me that it could be slow. I assume Sublime has some cache where it stores project files. Or am I wrong?

0 Likes

#4

Ideally, you would let the user use the goto anything panel and try working with on_activated. If that is for whatever reason not sufficient, you could also work with global states and try to hook the input view of the panel (yes, that is a view too), but I’m unsure how reliable that is. It has been a while since I had to mess with these.

Manually traversing the project folders to fill your own quick panel has the downsides of being slow and not respecting ST’s multiple pattern settings to in- and exclude files and folders. It could be emulated but would still be bothersome.

0 Likes