Re: [gtkmm] MessageDialog button callback?



Andreas B. Thun wrote:

Dear members,

how can I connect the Yes/No button to a callback?
Or is there a method I can overload?

if (type == Gtk::MESSAGE_QUESTION) {
    Gtk::MessageDialog dialog(*this, m_message, type, Gtk::BUTTONS_YES_NO);
    dialog.set_title(m_title);
    dialog.run();
}

Dialog::run() returns an int which is a value representing which button was pressed. In this case (where you're using Gtk::BUTTONS_YES_NO), you're going to get either Gtk::RESPONSE_YES or Gtk::RESPONSE_NO. Other such things for different buttons would include Gtk::RESPONSE_CANCEL, Gtk::RESPONSE_OK and so forth.

Please read the book:
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/ch13.html#id2499176

specifically in this case the on_button_question_clicked() function




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