From: Mikko Rasa Date: Mon, 16 Sep 2019 16:33:29 +0000 (+0300) Subject: Add a set_modal function for Dialog X-Git-Url: http://git.tdb.fi/?p=libs%2Fgltk.git;a=commitdiff_plain;h=9ef9547b31544637aca600ac65107d5b8028c39a Add a set_modal function for Dialog --- diff --git a/source/dialog.cpp b/source/dialog.cpp index 7b47b66..0b22e98 100644 --- a/source/dialog.cpp +++ b/source/dialog.cpp @@ -16,6 +16,18 @@ void Dialog::add_button(Button &button, int code) button.signal_clicked.connect(sigc::bind(sigc::mem_fun(this, &Dialog::response), code)); } +void Dialog::set_modal(bool m) +{ + if(m) + { + set_focus(); + if(state&FOCUS) + signal_grab_pointer.emit(); + } + else + signal_ungrab_pointer.emit(); +} + void Dialog::button_release(int x, int y, unsigned button) { Panel::button_release(x, y, button); diff --git a/source/dialog.h b/source/dialog.h index f7ec239..10519b1 100644 --- a/source/dialog.h +++ b/source/dialog.h @@ -37,6 +37,10 @@ public: response handlers and delete the dialog. */ void add_button(Button &, int); + /** Sets the modality of the dialog. When modal, the user can't navigate + away from the dialog. */ + void set_modal(bool); + virtual void button_release(int, int, unsigned); virtual bool key_release(unsigned, unsigned); protected: