I've copied this message to the Palm Developer's Forum, for those who might
consider writing infinite loops and wonder why they're not getting
ctlSelectEvent events on their buttons. Please forgive any errors in this
post, as I'm insane. :)
>when I reached the statement "event.eType == ctlSelectEvent", the compiler
>didn't get into the loop. The compiler didn't accept "event.eType ==
>ctlSelectEvent" at all. Would you mind explain to me what was happening?
What this essentially means is that they event you are receiving is NOT a
ctlSelectEvent. I apologize for telling you that it was; I should have
remembered better.
Here's how I'd go about fixing this... During debug, I'd set a breakpoint
on the line containing:
if (event.eType == ctlSelectEvent)
and check the value of event.eType. Compare this value to those in
<event.h> (somewhere about lines 56 and 94). What I expect is that the
event you're getting is a 1 (penDownEvent). You can confirm this by
looking in the "Developing Palm OS 3.0 Applications, Part 1" manual on page
102 where it describes the event flow for button resources.
When a button is tapped, a penDownEvent is generated first. Normally, user
code doesn't handle this, so the system will examine the penDownEvent and
generate a ctlEnterEvent. Again, user code normally does not handle
ctlEnterEvent; the system will examine it and generate a ctlSelectEvent,
assuming you lift the stylus on the button.
In an infinite loop, you are not providing the system the opportunity to
perform those checks and generate new events, so the only event I expect you
would see is a penDownEvent. You have two basic choices then:
1) Upon receiving the event, parse the structure to see if the point of the
penDownEvent is within your button's rectangle. If so, set your runLoop to
0. Optionally perform highlighting and checking of penUpEvent, since
normally the system does this for you (but can't do it when you're in an
infinite loop).
2) Alternatively (and easier), don't use a button. Where you'd normally put
your "Done" button, just place some text that says "Tap the screen to exit"
or something like that. Then change your code to something like this:
runLoop = 1;
while (runLoop)
{
if (EvtEventAvail())
{
EventType event;
EvtGetEvent(&event, 0);
if (event.eType == penDownEvent)
runLoop = 0;
}
}
FrmGotoForm(formID_main); // loop done; goto main form
and this *should* exit the loop as soon as you tap the screen anywhere. I
*think* this is a complete solution, but since I've not tried it myself, I'm
not completely sure. But try it and let me know how it goes.
---- --- -- -
Matthew D Moss
[EMAIL PROTECTED]