In article <35332@palm-dev-forum>, <[EMAIL PROTECTED]> wrote:

> I am using a repeating button to do continuous increment of a number in my
> application.  However, when I press the button (in emulator), I get several
> ctlRepeatEvent
> very quickly (the number increment very fast) instead of every 1/2 as
> indicated by the reference manual.  What would the problem be?
> 
> Thanks.
> Jacky

When handling the repeat event, I add a constant delay to the event
structure, like this:

event->data.ctlRepeat.time += RepeatDelay;

The delay is defined as 0.2 seconds like this:

#define RepeatDelay (SysTicksPerSecond() / 5) /* 0.2 seconds */

You can download the whole source code (GPL) of "Battery Panel" at
<http://www.geocities.com/SiliconValley/Cable/5206/batterypanel.htm>. This
trick was shown in this forum some time ago (see below).

Remo Hofer

----
Date: Wed, 7 Jun 2000 18:08:16 +0200
From: Bob Ebert <[EMAIL PROTECTED]>
Subject: Re: Repeating Buttons...
Newsgroups: palm-dev-forum
Message-Id: <13573@palm-dev-forum>


At 5:00 PM +0200 06/7/00, McKee, Kevin L. wrote:
>Does anyone have a quick trick to slow down the repeating action when a
>repeating button is pressed.  Currently when I press the repeating button it
>either jumps by twos or threes.

Repeating buttons normally delay for you.  It looks like the repeat
interval is 1/2 a second until it starts repeating, then about 10 times per
second (every 9 ticks) after that.  ...that does seem sort of fast!

It's easy to slow it down.  There's a value in the ctlRepeat event
(ctlRepeat.time) that controls when the next repeat event will be set.  So
if you want to change the repeat interval to two times a second, just add
41 to the value stored there.  (So it goes from an interval of 9 ticks to
one of 50 ticks.)

Of course, you should probably make these values dependent on the ticks per
second result, just for correctness.

                                        --Bob

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to