[Vala] Prevent a MessageDialog from being closed with Esc



Hi all,

is there a way to prevent a MessageDialog from closing with Esc key?


var messagedialog = new MessageDialog((Window)widget.get_toplevel(), DialogFlags.MODAL, MessageType.ERROR, ButtonsType.NONE, _(@"Are you sure you want to delete the directory $file?")); messagedialog.add_action_widget(new Button.with_mnemonic(_("_Yes")), ResponseType.YES); messagedialog.add_action_widget(new Button.with_mnemonic(_("_No")), ResponseType.NO); messagedialog.add_action_widget(new Button.with_mnemonic(_("_Remove")), ResponseType.APPLY); messagedialog.secondary_text = _(@"This directory and all its files and subfolders are permanently removed from your storage. Click '$(_("Remove"))' if you just want to remove it from your current project.");
messagedialog.show_all();
messagedialog.delete_event.connect( (event) =>
{
    return true; // It's just a test, looks like it does not make a differencewhat i return
});
var response = messagedialog.run();


My "working" solution for now is this, may there is a better way?


messagedialog.hide_on_delete();
int response = ResponseType.DELETE_EVENT;
do
{
    messagedialog.show_all();
    response = messagedialog.run();
} while(response == ResponseType.DELETE_EVENT);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]