From 9ef9547b31544637aca600ac65107d5b8028c39a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 16 Sep 2019 19:33:29 +0300 Subject: [PATCH] Add a set_modal function for Dialog --- source/dialog.cpp | 12 ++++++++++++ source/dialog.h | 4 ++++ 2 files changed, 16 insertions(+) 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: -- 2.43.0