[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: newbie key binding question
- From: Sirisha Muppavarapu <sirisha muppavarapu veralight com>
- To: Michael Cronenworth <mike cchtml com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: newbie key binding question
- Date: Mon, 24 Nov 2008 15:01:07 -0700
Hi
Overload on_key_pressed() method and inside, handle the keypress event.
This is what I did in my project. Hope it helps.
ClassX is my class extending from Gtk::Window.
bool ClassX::on_key_pressed(GdkEventKey* event)
{
try{
if(!event)
return false;
switch (event->keyval)
{
case GDK_F1: {
action1();
break;
}
case GDK_F2: {
action2();
break;
}
case GDK_F3: {
action3();
break;
}
case GDK_F4: {
action4();
break;
}
default: {
break;
}
}
catch(exception &e) {
}
// Returning true would stop the event now
return false;
}
On Mon, 2008-11-24 at 11:23 -0600, Michael Cronenworth wrote:
> Hi all, I'm new to GTK+ usage, but I'm learning quickly.
>
> I wish to set up a key (say, F4) and have it attached to a button, so
> when F4 is pressed the button's signal is emitted just like a mouse
> click. I'm familiar with setting up global accelerators (CTRL+Q, etc),
> but all I want is a single key binding on one button widget on one
> widget instance. This will not be used globally and only one time. I've
> seen the GtkBinding page and how it describes RC file usage, but I'd
> rather not use such a beefy method for just one key...
>
> Any pointers are welcome.
>
> Thanks,
> Michael
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]