我有一个处理程序函数:
bool test( const Glib::ustring& uri )
{
MessageBoxA( NULL, "hello", NULL, 0 );
return true;
}
然后我连接
label2.set_markup( "<a href="http://www.google.com">Google</a>" );
sigc::connection conn = label2.signal_activate_link().connect( sigc::ptr_fun( test ) );
我不明白为什么这不起作用。当我点击谷歌时,我可以看到它使用的是默认的URI处理程序,而不是我的。
我必须确保我的函数在默认值之前被调用。我猜,如果默认的信号处理程序返回true,因此信号不会传播,会发生什么?
/** Connects a signal to a signal handler.
* For instance, connect( sigc::mem_fun(*this, &TheClass::on_something) );
*
* @param slot The signal handler, usually created with sigc::mem_fun(), or sigc::ptr_fun().
* @param after Whether this signal handler should be called before or after the default signal handler.
*/
sigc::connection connect(const SlotType& slot, bool after = true)
{ return sigc::connection(connect_(slot, after)); }
这是正确的代码:
label2.signal_activate_link().connect( sigc::ptr_fun( test ), false );