if (buttonPressed == 0) FrmGotoForm (MainForm); handled = true;A FrmGotoForm queues up the following events in the queue:
1) frmCloseEvent - this is to the current form which closes the current form.
2) frmLoadEvent
3) frmOpenEvent
2 & 3 are used to open the form that you want to display.
Question: When FrmGotoForm (MainForm); is executed, is handled = true; executed immediately following FrmGotoForm or skipped? Why?
To date, we have used FrmAlert, FrmCustomAlert, and FrmGotoForm calls in our applications. FrmAlert and FrmCustomAlert display modal dialogs and usually have enough controls to handle most situations. The question arrises, what if we need more controls that these calls allow? The answer is that we need to write our own more complicated Modal Dialog Box using FrmPopupForm which needs its own event-handler. Further, unlike FrmGotoForm, FrmPopupForm does not send a frmCloseEvent to the current form; therefore, when creating the modal dialog box, check both modal and save behind; otherwise, the logic is similar to a regular form. One last thing. A FrmReturnToForm (0); returns to the last form loaded which is the form that displayed your modal dialog box.
The Palm OS treats a number of UI objects as "controls." What's nice about this is that the system treats these controls in a consistent manner. Thus understanding a few of these objects gives us an understanding of most.
Controls can be broken down into the following objects:
To date, we have seen example of a select event such as the user tapping on a button. Once an object is selected, a select event can be tested and used.
Some sample select events include:
Many times, when responding to an event, we want to know the resource ID of the object involved. Table 9.1 on 224-5 gives a good summary of where to find the resouce ID associated with the given event.
Last lecture, we programmed fields. We will continue to program fields and add other UI elements to our bag of tricks.
For the next two lectures we will implement the following Validate screen.
Things to note:
A user tapping within a list queues up a lstSelectEvent when the tap is released. The API call LstGetSelection can be used to determine which list item the user selected. The function prototype is:
Int16 LstGetSelection (const ListType *listP);LstGetSelection takes a pointer to a list and returns the number of the item selected starting with item # zero. If no item is selected, then the constant noListSelection is returned as defined in the Palm OS header file.
Should you want the actual list text, use LstGetSelectionText which has the following function prototype:
Char *LstGetSelectionText (const ListType *listP, Int16 itemNum);So how might we incorporate this into a program? Let's look at the following code:
case ctlSelectEvent: if (eventP->data.ctlEnter.controlID == MainTitleSelTrigger) { pForm = FrmGetActiveForm(); wIDList = FrmGetObjectIndex (pForm, MainTitleList); pList = (ListPtr) FrmGetObjectPtr(pForm, wIDList); whichone = LstPopupList(pList); label = LstGetSelectionText (pList, whichone); if (label == NULL) label = defaultValue; ctl = GetObjectPtr(MainTitleSelTrigger); CtlSetLabel(ctl,label); handled = true; }
Method 1: Use a Modal form which enables the Help ID option. The Help ID option allows the programmer to put in the string ID for the help to be displayed. A help icon shows up in the upper right hand corner of the display.
Method 2: We can code some form object to automatically display a help string in a help form. This is what I want to do with the "Terms of Use" push button.
Logic for Method 2 might look like:
else if (eventP->data.ctlEnter.controlID == ValidateTermsOfUsePushButton) { FrmHelp (ValidateString); ctl = GetObjectPtr(MainTermsOfUsePushButton); CtlSetValue(ctl, 0); handled = true; break; }