Sublime Forum

Display a dialog box?

#1

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!

0 Likes

#2

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 :wink:

0 Likes

#3

Redisplaying the input panel is how I handled that problem. See the get_username/get_password methods in 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:

sublime.set_timeout(self.get_password, 50)

in on_done_username.

0 Likes

#4

[quote=“bgreenlee”]Redisplaying the input panel is how I handled that problem. See the get_username/get_password methods in 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:

sublime.set_timeout(self.get_password, 50)

in on_done_username.[/quote]

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!

0 Likes