I just took a look at the code and the solution looks a LOT more complicated
than it needs to be: the system will do most of the work for you with popup
lists. It is possible the chapter has other goals in mind, such as showing
you how to handle events, but the basics are pretty simple.

All you need is to know when the user makes a selection from the popup list
so you can recalculate the string. To do this you need to look for the
popSelectEvent event in your event code: the system takes care of updating
the trigger automatically and updates the list's current selection:

  case popSelectEvent:
      DisplayNumber();  // gets current list value and updates field
      handled = false;  // lets OS handle trigger label update for you
      break; 

That should be all you need.

If you need to get the list's current selection, it is provided as part of
the popSelectEvent with the EventType data structure. So, to get the
selection in the popSelectEvent, your code looks like

  precision = eventP->data.popSelect.selection;

Finally, if you need to update the trigger's label with something other than
the text of the current list selection, you can do so in the popSelectEvent
also, but you must return 'true' from your code so that the system won't try
to update the label itself;

  case popSelectEvent:
      // Use eventP->data.popSelect.selection to create
      // a new, non-local label
      . . .
      // Draw the new trigger label
      CtlSetLabel(eventP->data.popSelect.controlP, myNewLabel);
      handled = true;
      break;

Take a look at the Palm OS Companion document with the SDK, especially the
chapter dealing with UI. Another good reference is the Expert Case Studies
online course, which you can take from your web browser and is free until
the end of the year (see www.palmsource.com/developers for more info).

Good luck,
JB @ PalmSource


on 9/4/02 2:47 PM, Al Smith at [EMAIL PROTECTED] wrote:

> Hello,
> 
> I have been reading "Advanced Palm Programmimg" by Steve Mann, page 79.
> where it states the Popup Handling,,Im kind of confused, and when I tried
> running the code I get several error from this case statement;
> // Popup triggers
> 
> case ctlEnterEvent:
> ctlP = GetObjectPtr ( eventP->data.ctlSelect.controlID );
> if ( ctlP->style == popupTriggerCtl )
> {
> HandlePopup ( eventP->data.ctlSelect.controlID );
> handled = true;
> DisplayNumber ();
> }
> break;


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

Reply via email to