]> git.tdb.fi Git - libs/gltk.git/commitdiff
Prevent problems if a button press handler throws
authorMikko Rasa <tdb@tdb.fi>
Mon, 3 Aug 2009 12:24:48 +0000 (12:24 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 3 Aug 2009 12:24:48 +0000 (12:24 +0000)
Add optional text parameter to Toggle constructor

source/button.cpp
source/panel.cpp
source/toggle.cpp
source/toggle.h

index ec9901620d5d562ffd3b820316f69c0c2f829d44..aecfd32fe0d004a56c8201d0da5f33f32599c636 100644 (file)
@@ -44,11 +44,11 @@ void Button::button_release(int x, int y, unsigned btn)
 {
        if(pressed && btn==1)
        {
-               if(geom.is_inside_relative(x, y))
-                       signal_clicked.emit();
-               
                state&=~ACTIVE;
                pressed=false;
+
+               if(geom.is_inside_relative(x, y))
+                       signal_clicked.emit();
        }
 }
 
index a708873edbeb4a7df6e2a2a1b097dfb057df6ced..aeca9e71a61e83d6889e351cb678ddd1493f2741 100644 (file)
@@ -95,11 +95,13 @@ void Panel::button_release(int x, int y, unsigned btn)
 {
        if(pointer_grab>0)
        {
-               const Geometry &cgeom=pointer_focus->get_geometry();
-               pointer_focus->button_release(x-cgeom.x, y-cgeom.y, btn);
+               Widget *wdg=pointer_focus;
 
                if(btn==pointer_grab)
                        set_pointer_focus(get_child_at(x, y), 0);
+
+               const Geometry &cgeom=wdg->get_geometry();
+               wdg->button_release(x-cgeom.x, y-cgeom.y, btn);
        }
        else if(geom.is_inside_relative(x, y))
        {
index 8c264e4c9b4486194cfca18978c64c1d52a0a8c1..9fbd098ae0783aab8a4e724e1975b85864bc8b48 100644 (file)
@@ -14,8 +14,9 @@ using namespace std;
 namespace Msp {
 namespace GLtk {
 
-Toggle::Toggle(const Resources &r):
+Toggle::Toggle(const Resources &r, const string &t):
        Widget(r),
+       text(t),
        pressed(false),
        value(false),
        exclusive(false)
index bdb1b31c42808e2a2bb6e4b4bc3b67912a125837..794636ec1e4617b8a0064adb46c8bdb902bdbe11 100644 (file)
@@ -38,7 +38,7 @@ private:
 public:
        sigc::signal<void, bool> signal_toggled;
 
-       Toggle(const Resources &);
+       Toggle(const Resources &, const std::string & =std::string());
 
        void set_text(const std::string &);
        void set_exclusive(bool);