Supressing Keystrokes in Photon

Hello,

I have an app created with PhAB, that cycles through a bunch of images using
the arrow keys.

I run into a problem when the user justs sits on the arrow keys. All those
events get stored up. When the user finally lets go of the key, the cycling
continues until all the keyboard events are processed.


Is there a way to stop events immediately when the key is released?

Thanks.
Tom

Years ago this was a problem in DOS land with Lotus 1-2-3. There was a product
called Cruise Control which was designed to overcome this problem. I think all
it did was every time an event was received, consume all events (ie empty the
buffer) and only act on the last one. That way your program should be able to
keep up (doing less redraws or whatever) and it stops as soon as the key is
released.

Not sure how this will fit you model, but it is something to consider.

Tom Wilson wrote:

Hello,

I have an app created with PhAB, that cycles through a bunch of images using
the arrow keys.

I run into a problem when the user justs sits on the arrow keys. All those
events get stored up. When the user finally lets go of the key, the cycling
continues until all the keyboard events are processed.

Is there a way to stop events immediately when the key is released?

Thanks.
Tom

Donald Backstrom <donaldb@cstgroup.com.au> wrote:

Years ago this was a problem in DOS land with Lotus 1-2-3. There was a product
called Cruise Control which was designed to overcome this problem. I think all
it did was every time an event was received, consume all events (ie empty the
buffer) and only act on the last one. That way your program should be able to
keep up (doing less redraws or whatever) and it stops as soon as the key is
released.

In Photon, you could do it by using a workproc and a global counter
variable:

In the key callback, increment the counter and if was zero, attach
the workproc.

In the workproc, look at the counter – it tells you how many key
events you have received since the workproc was attached. Then
clear the counter, update your drawing, and remove the workproc by
returning Pt_END.


Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.