我有一个处理函数:
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处理程序,而不是我的。
答案 0 :(得分:1)
我必须确保在默认情况下调用我的函数。我猜测会发生什么,默认信号处理程序返回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 );