]> git.tdb.fi Git - libs/gltk.git/commitdiff
Add a set_modal function for Dialog
authorMikko Rasa <tdb@tdb.fi>
Mon, 16 Sep 2019 16:33:29 +0000 (19:33 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 16 Sep 2019 16:38:32 +0000 (19:38 +0300)
source/dialog.cpp
source/dialog.h

index 7b47b66e9571c80800ae9bcd152fd0e1ea06b250..0b22e9874a8d1578266fe6b98a95ddca84cf3cc5 100644 (file)
@@ -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);
index f7ec239897caf9dbba03e482da60f348d0fd2adb..10519b178928c495bf022ba3d0a8e40487599c5f 100644 (file)
@@ -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: