Home Download Buy Blog Forum Support

Display a dialog box?

Display a dialog box?

Postby s992 on Fri Feb 24, 2012 7:46 pm

I'm working on my first Sublime plugin, and I need to collect a few pieces of information from the user.

I'm aware of the show_input_panel method, but as far as I know it only allows you to collect a single piece of information. Is there a way to create a dialog box that collects information from multiple fields? Alternatively, is there a way to get the same type of UI that is used for search/replace across entire directories/projects(CTRL+SHIFT+F)?

Either of these options would work fine for me, the only caveat is that I need to be able to collect at least five unique pieces of information from the user.

Thanks!
s992
 
Posts: 3
Joined: Fri Feb 10, 2012 7:23 pm

Re: Display a dialog box?

Postby agibsonsw on Fri Feb 24, 2012 10:58 pm

Hi. I'm new to this myself and hope you receive a fuller response than I can supply. But, in the meantime, could you not show the input panel five times? It would happen so quickly that it would seem like a continuous dialogue to the user.

You would probably need a simple counter variable to track the five (consecutive) responses. And you might set this counter to zero in the on_cancel event. That is, if they press Escape at any point the whole dialogue is abandoned. I think you might also need to use a timeout (set_timeout) in the 'on_done' event, before displaying the next panel. That is, there needs to be a slight delay before showing the panel again, otherwise the on_done event might still be running.

The Find in Files features seems to display three input panels, but I gave this a quick go and I'm not sure that we can show more than one at a time.

Alternatively, I believe the output panel can be editable. However, as it is intended for output, it may prove tricky to manage for input(?).

Hopefully someone with knowledge will contribute ;)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Display a dialog box?

Postby bgreenlee on Mon Feb 27, 2012 12:30 am

Redisplaying the input panel is how I handled that problem. See the get_username/get_password methods in https://github.com/bgreenlee/sublime-gi ... y#L145-172

The only trick is that if you try to display the next input panel immediately after the last one is finished, it won't appear. You need to introduce a very slight delay, which is why you see:

Code: Select all
sublime.set_timeout(self.get_password, 50)

in on_done_username.
bgreenlee
 
Posts: 22
Joined: Wed Jul 20, 2011 8:02 pm
Location: Seattle, WA

Re: Display a dialog box?

Postby s992 on Mon Feb 27, 2012 5:53 pm

bgreenlee wrote:Redisplaying the input panel is how I handled that problem. See the get_username/get_password methods in https://github.com/bgreenlee/sublime-gi ... y#L145-172

The only trick is that if you try to display the next input panel immediately after the last one is finished, it won't appear. You need to introduce a very slight delay, which is why you see:

Code: Select all
sublime.set_timeout(self.get_password, 50)

in on_done_username.


Interestingly enough, you've solved my problem without me having to write any code. I was unaware of the GitHub plugin you had linked, and it was exactly what I was planning on writing. You should see if you can get it in to the Sublime Text Packages repository on GitHub!
s992
 
Posts: 3
Joined: Fri Feb 10, 2012 7:23 pm


Return to Plugin Development

Who is online

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