From: Mikko Rasa Date: Mon, 3 Aug 2009 12:24:48 +0000 (+0000) Subject: Prevent problems if a button press handler throws X-Git-Tag: 1.1~3 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=1a5f227ac945bc9e6449d1552e5d9eb4c1c196fb;p=libs%2Fgltk.git Prevent problems if a button press handler throws Add optional text parameter to Toggle constructor --- diff --git a/source/button.cpp b/source/button.cpp index ec99016..aecfd32 100644 --- a/source/button.cpp +++ b/source/button.cpp @@ -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(); } } diff --git a/source/panel.cpp b/source/panel.cpp index a708873..aeca9e7 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -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)) { diff --git a/source/toggle.cpp b/source/toggle.cpp index 8c264e4..9fbd098 100644 --- a/source/toggle.cpp +++ b/source/toggle.cpp @@ -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) diff --git a/source/toggle.h b/source/toggle.h index bdb1b31..794636e 100644 --- a/source/toggle.h +++ b/source/toggle.h @@ -38,7 +38,7 @@ private: public: sigc::signal signal_toggled; - Toggle(const Resources &); + Toggle(const Resources &, const std::string & =std::string()); void set_text(const std::string &); void set_exclusive(bool);