2012-03-15 20 views
0

我有一個處理函數:GTK activate_link不能與標籤uri一起使用? gtkmm Gtk :: Label和signal_activate_link()?

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

任何人對此有什麼想法?這讓我有點瘋狂 – loop 2012-03-15 17:10:59

回答

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);