Sublime Forum

Waiting for show_input_panel to succeed

#1

Hello sublimers,

as I’m fairly new to Sublime, I’m messing around with plugin development. I’m stuck at one point where it is about requesting user input.
The goal is to show multiple input panels after each other. Using Window.show_input_panel(…) multiple times seems to skip all previous calls and just pop out the most recent called panel. Why is requesting user input a synchronous process in sublime? Is there a reason for it?
I seriously don’t want to go about it via EBC patterns or something, I’d rather like to wait for the panel to succeed (or cancel/change, doesn’t matter).

Is using conditional objects a proper way to do so? Should I just sleep(…) until a state variable changes?
What is common practice?

Yours
Frank

1 Like

#2

Using callbacks is the right thing to do, otherwise the application would be locked up while your plugin is running. Take a look at Packages/Default/goto_line.py for an example

1 Like

#3

Thanks for the quick reply!
It makes perfectly sense considering plugins are not run in threads. Anyways, as I said, I’d like to avoid the EBC pattern. Imagine requiring 3 inputs, it’d result in 3 methods to process the callback (considering not using a state flag or something). Sounds like a bit overhead to me - how would you manage keeping the code clear?

1 Like

#4

Actually that is my first attempt in python - this is also the reason why I am asking such a ‘newbish’ question.
Thanks for your reply - at least I have some keywords to search for on the web!

EBC is the abbreviation for “event based components” and comes from the flow design patterns. Googling for this pattern actually yields this thread on the first page… The name or pattern may come from the C# (hence the name events) world which I am traveling in. Shortened explanation: Each component of your solution does one job and is event-driven. Methods won’t be called for the job! In your terminal (another component) you attach the components to each other and run one starter or working method which will eventually trigger all the other needed and used events in your other components.

1 Like

#5

If you think using multiple method calls to deal with the input of an input panel is a lot (even though it’s definitely the correct way to do it) then maybe you need to rethink why you need 3 input panels.

Can you give us a vague idea of the plugin’s functionality and why you might need to ask three things one after the other? Sounds like a usability nightmare to me. Maybe there’s a better way… (Maybe not.)

1 Like