Re: Key presses and releases



Hi,

Maybe you can do like this:

void onKeyPressed(...) {
  if(!keyAlreadyPressed) {
     // space toggled (now active)
     keyAlreadyPressed = true;
     //... additional handling
  }
}

void onKeyReleased(...) {
   // space toggled (now inactive)
   keyAlreadyPressed = false;
}

keyAlreadyPressed is a bool private member or global variable.

2009/12/23, Lyle Underwood <lyleunderwood gmail com>:
> I'm so close to finishing up this application now, I'm just putting some
> polish on it.
>
> I have a drawing area in a viewport for scrolling. I want to add the
> ability to pan with the mouse, but since the user is usually drawing
> onto the drawing area I wanted them to use the spacebar to pan. So, you
> hold down spacebar and drag around to pan, just like in photoshop, gimp,
> etc..
>
> I'm pretty sure I'm not going to have any problem with the actual
> panning, but I can't figure out how to use the spacebar as a toggled
> state. It seems the events are triggered by some kind of key repeat,
> because when I hold down space I get a huge series of press events and
> release events. So is there some way that I can tell if the spacebar is
> held down constantly? I was looking through the GdkEventKey struct and
> couldn't find a solution.
>
> Also, I wanted to ask, what's the easiest way to get the selected row in
> a TreeView to redraw?
>
> Thanks.
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
>


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