Home Download Buy Blog Forum Support

Waiting for show_input_panel to succeed

Waiting for show_input_panel to succeed

Postby fjdumont on Thu Oct 13, 2011 9:38 am

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
fjdumont
 
Posts: 5
Joined: Thu Oct 13, 2011 9:32 am

Re: Waiting for show_input_panel to succeed

Postby jps on Thu Oct 13, 2011 1:16 pm

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
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Waiting for show_input_panel to succeed

Postby fjdumont on Thu Oct 13, 2011 1:55 pm

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?
fjdumont
 
Posts: 5
Joined: Thu Oct 13, 2011 9:32 am

Re: Waiting for show_input_panel to succeed

Postby fjdumont on Mon Oct 17, 2011 2:13 pm

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.
fjdumont
 
Posts: 5
Joined: Thu Oct 13, 2011 9:32 am

Re: Waiting for show_input_panel to succeed

Postby alexrussell on Mon Oct 17, 2011 2:26 pm

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.)
alexrussell
 
Posts: 74
Joined: Fri Jul 15, 2011 9:06 am


Return to Plugin Development

Who is online

Users browsing this forum: Alexa [Bot] and 9 guests