[Xfc-dev] How to implement system wide HotKey by xfc?

Jeff Franks jcfranks at tpg.com.au
Thu May 26 13:23:58 CEST 2005


xl g wrote:

>I write a program need system wide hot key, but i can't find
>corresponding class in the xfc and GTK. Are anyone can give me some
>tip?
>  
>
Sorry for the late reply but I've been away. You need to install a "key 
snooper" function. GTK will call the key snooper function on all key 
events before delivering the key event normally.

In XFC you install a key snooper function by connecting a function slot 
to the G::Main::key_snooper_signal, like this:

#include <xfc/main.hh>

G::Main::key_snooper_signal.connect(sigc::mem_fun(this,  
&MyWindow::key_snooper_function));

Then define your key_snooper_function() like this:

bool
MyWindow::key_snooper_function(const Gdk::EventKey& key_event)
{
}

This function should return false to prevent further snooping or true to 
continue snooping. Have a look at the Gdk::EventKey and 
G::Main::KeySnooperSignal class docs.

Jeff.




More information about the Xfc-dev mailing list