Sublime Forum

Show an ok_cancel dialog

#1

Hello everybody,

I’m writing my first plugin for sublime and I need some help. I want to show some kind of ok_cancel dialog to prevent the user for overwriting a configuration file, and I don’t know how to do that. The ok_cancel_dialog function is not available on the build 2181. Any suggestions?

Thank you very much!

0 Likes

#2

Why not just upgrade to 2187 or higher where the ok_cancel_dialog function is available?

0 Likes

#3

Hi jbjornson ,

Well, just because these are development versions if I’m not wrong. I want to work with the latest stable.

Thanks!

0 Likes

#4

Fair enough. Maybe you could display an input panel on the view that expects a yes/no value?

import sublime, sublime_plugin

class ExampleCommand(sublime_plugin.WindowCommand):
    def run(self):
        self.window.show_input_panel('Do you really want to overwrite the configuration file (yes/no):', 'No', lambda s: self.handle_response(s), None, None)

    def handle_response(self, answer):
        if answer.upper() in 'Y', 'YES']:
            print 'About to overwrite the configuration file'
        else:
            print 'Abort configuration file overwrite'
0 Likes

#5

Hm… it’s a good approach by the moment, and it works fine. Thak you very much!

0 Likes