Re: [gtkmm] Signal emission stop
- From: "Andrew E. Makeev" <andrew solvo ru>
- To: Martin Schulze <MHL Schulze t-online de>
- Cc: gtkmm-main <gtkmm-list gnome org>
- Subject: Re: [gtkmm] Signal emission stop
- Date: Thu, 24 Apr 2003 10:44:30 +0400
Martin Schulze wrote:
Am 2003.04.23 13:41 schrieb(en) Andrew E. Makeev:
Hi,
Look at the simple example below, and explain, please, how could I
stop SigC signal emission?
For gtk(mm) signals the signal emission can be stopped by returning true
(or was it false? => we have to look at the docs!) in the signal handler.
Yes, it should be true for <signal_..._event>, and
<signal>.emission_stop () for named GTK signals.
For you own SigC signals you need a Marshaller (see marshal.h) to
achieve the same:
class MyMarshal {
// both typedefs must be defined.
typedef bool InType;
typedef bool OutType;
public:
OutType stopped_emission;
// Return final return code.
OutType value()
{ return stopped_emission; }
// Captures return codes and returns TRUE to stop emission.
bool marshal(const InType& stop_emission)
{ stopped_emission=stop_emission; return stop_emission; }
MyMarshal() : stopped_emission(false) {}
};
Your example would read:
class MyClass : public SigC::Object {
public:
...
SigC::Signal0<bool,MyMarshal> test_signal;
...
};
void MyClass::some_method () {
test_signal.connect (SigC::slot (*this, &MyClass::f1));
test_signal.connect (SigC::slot (*this, &MyClass::f2));
}
bool MyClass::f1 () {
if (<expr> == true)
return true; // return true to stop emission. function f2 won't
be called
else
return false; // continue signal emission
}
bool MyClass::f2 () {
return false;
}
Thanks a lot, everything works great now, just when I added
MyMarshal::default_value () method :).
Regards,
-andrew
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]