Question dialog should give focus to OK Button: Closes #6506

This commit is contained in:
Timo Kluck 2013-03-11 13:36:18 -07:00 committed by Jim Nelson
parent 842e390ed1
commit 149c030692

View file

@ -30,6 +30,12 @@ abstract class AlertDialog : Object {
return (Gtk.Box) dialog.get_message_area();
}
public void set_focus_response(Gtk.ResponseType response) {
Gtk.Widget? to_focus = dialog.get_widget_for_response(Gtk.ResponseType.OK);
if (to_focus != null)
to_focus.grab_focus();
}
// Runs dialog, destroys it, and returns selected response
public Gtk.ResponseType run() {
Gtk.ResponseType response = (Gtk.ResponseType) dialog.run();
@ -79,6 +85,9 @@ class QuestionDialog : AlertDialog {
// this must be done once all the packing is completed
get_message_area().show_all();
// the check box may have grabbed keyboard focus, so we put it back to the button
set_focus_response(Gtk.ResponseType.OK);
is_checked = checkbox_default;
}