Re: keyboard events?

Yea, the documentation is a bit lacking in that part, I also had some
problems with that.

Here's an example, in my case to check for the esc key (and hide the window).

on constructor:

this->add_events( Gdk::KEY_PRESS_MASK );

this->signal_key_release_event().connect ( sigc::mem_fun(*this,
&YourClass::onKeyRelease) );

the function:

bool YourClass::onKeyRelease(GdkEventKey *event)
if (event->keyval == GDK_KEY_Escape)

return true;

To see which keys to compare, open the file gdkkeysyms.h (in
gtk-3.0/gdk/ folder)

On Sun, Sep 4, 2011 at 10:37 PM, D. R. Evans <doc evans gmail com> wrote:
> What documentation do I need to read in order to understand to detect
> keyboard events (in particular, detecting and timing shift keys
> depressions)? I don't see anything in the basic documentation, so I imagine
> that keyboard handling must be the responsibility of one of the several
> other packages that got installed at the same time.
> (I guess that that means keyboard handling isn't really part of gtkmm and
> is therefore a bit off-topic here. Sorry. In my experience keyboard
> handling is part of the same system as the graphical interface, but that
> doesn't seem to be true in the case of gtkmm.)
> I've been flailing around in the documentation for some time trying to make
> progress on this, and have got nowhere.
>  Doc
> PS To make it even more puzzling to the newcomer, I see that the Widget
> class has member functions such as on_key_press_event() that take something
> called a GdkEventKey*, but the GdkEventKey class isn't mentioned in the
> gtkmm documented list of classes at
> /usr/share/doc/gtkmm-3.0/reference/html/annotated.htmŀ, and the reference
> to the class in the description of Widget isn't clickable, so it's
> basically a dead-end :-(
> --
> Web:
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]