Please excuse any "typos" I've made herein, and thanks in advance for help ...
I'm a relatively new palm pilot programmer. I'm trying to load a "popup" form containing a list and a "Quit" button for users who choose not to select any items from the list. The problem is that the event handler for the new form isn't receiving any events generated by the new form's resources - not by pressing the button (which should generate ctlSelectEvent) nor by selecting a list item (which should generate lstSelectEvent). The list is being drawn correctly. I know the event handler for the new form is being called for the frmLoadEvent and "other" events (such as: penDownEvent, penUpEvent, etc.). The problem seems to be that neither the button nor the list (see code below) is even generating the desired events. It is as if my popup form does not have a button nor a list resource.
Help, please. Any ideas as to why this is happening? What in the world am I doing wrong? I have typed in some of my code below. I am trying to follow a "classic", text-book method of bringing up a Modal Dialog with its own, full event handler.
I invoke the new form by calling the following in MainManuHandleEvent (that is, this popup form is invoked from a menu item):
FrmPopupForm (newFormID);
In AppEventHandler, I set the event handlers, as follows:
if (event->eType == frmLoadEvent) {
int formID = event->frmLoad.formID;
FormType* form = FrmInitForm (newFormID);
FrmSetActiveForm (form);
switch (formID) {
case MainForm:
FrmSetEventHandler (form, MainFormHandleEvent);
break;
case NewForm:
FrmSetEventHandler (form, NewFormHandleEvent);
break;
}
handled = true;
}In NewFormHandleEvent, I draw the new form containing a list, as follows:
Boolean NewFormHandleEvent (EventType* event) {
Boolean handled = false;
FormType* form = FrmGetActiveForm ();
ListType* list = (ListType*) FrmGetObjectPtr (form,
FrmGetObjectIndex (form, listID));
switch (event->eType) {
case frmOpenEvent:
// THE CODE DOES GET HERE ...
LstSetSelection (list, -1);
LstsetDrawFunction (list, ListDraw);
LstSetListChoices (list, NULL, MAX_LIST);
FrmDrawForm (form);
handled = true;
break;
case ctlSelectEvent:
// THE CODE NEVER GETS HERE ...
FrmReturnToForm (0);
handled = true;
break;
case lstSelectEvent:
// THE CODE NEVER GETS HERE EITHER ...
int idx = LstGetSelection (list);
// do something with the selected list item
FrmReturnToForm (0);
break;
default:
handled = true;
break;
}
return handled;
}My listDraw function looks like this:
void ListDraw (short int idx,
RectangleType* rect,
Char** text) {
char* str = "dummy";
WinDrawChars (str, strLen (str), rect->topleft.x,
rect->topLeft, y);
}-- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
