On Thu, 2004-04-01 at 02:45, Eddie Gomez wrote:
> Given the following code snippet:
>
> // track the pen
> do
> {
> EvtGetPen(&x, &y, &penDown);
> // Don't do anything if no pen movement
> if ((x != prevX || y != prevY))
> {
> WinDrawLine(prevX, prevY, x, y);
> prevX = x;
> prevY = y;
> }
>
> } while (penDown);
The Palm is concatenating mouse move events so that your application
isn't overwhelmed...but this leads to clunky lines.
Try something like this instead, inside your main event loop:
(This is off the top of my head, and so is likely horribly broken. It's
just meant as a hint.)
int MainEventLoop()
{
EventType e;
Int16 x,y;
Boolean pendown;
while (e.eType != appStopEvent) {
// bTrackingMouse is a boolean you set elsewhere
// to indicate you're interested in tracking the
// mouse ptr.
if (bTrackingMouse) {
// hard on batteries, but this gives you
// the best response. Increase the '0'
// if you can.
EvtGetEvent(&e,0);
EvtGetPen(&x,&y,&pendown);
if (pendown) {
// if first time, draw from x,y to x,y
// if not first time, draw a line from
// the old x,y to this new x,y.
}
// The pen has been lifted. Fall out
// of this action.
if (!pendown) {
bTrackingMouse=false;
}
} else {
EvtGetEvent(&e,evtWaitForever);
}
if (e.eType == penDownEvent) {
bTrackingMouse=true;
}
}
}
-Ken
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/