I am generating the contents for the popup trigger dynamically as in the sample
code using, popSelectEvent & penUpEvent. and set the value of handled to false.
Why does it still not work?? What am I doing wrong?
case popSelectEvent:
// See if this is our special Poptrigger:
if ( eventP->data.popSelect.controlID == TmLgClientTrig )
{
// First set a flag indicating one of our special
Poptrigger
// Fields was hit -- we will look for this flag when
the
// penUpEvent happens, immediately after this
popSelectEvent.
// We redraw the field in penUpEvent, not here, to
prevent it
// from being overwritten by the Poptrigger resource.
gbTmLgClientTrigSelected = true;
// Extract the selected string from the list:
tmp = LstGetSelectionText((ListPtr)
eventP->data.popSelect.listP,
eventP->data.popSelect.selection );
lstP = (ListType *) FrmGetObjectPtr(frmP,
FrmGetObjectIndex(frmP,
TmLgClientLst));
// Clear out the field's old texthandle, and create a
new one:
frmP = FrmGetActiveForm();
fldP = (FieldPtr)FrmGetObjectPtr( frmP,
FrmGetObjectIndex( frmP, TmLgClientLst));
oldText = FldGetTextHandle( fldP );
newText = (MemHandle) MemHandleNew( StrLen(tmp)+1 );
itemNum = LstGetSelection(lstP);
// Copy the string from the list into this new chunk:
StrCopy( (Char *)MemHandleLock( newText ), tmp );
MemHandleUnlock( newText );
// Set the field's text to be this chunk:
// Do not redraw the field just yet...
FldSetTextHandle( fldP, newText );
LstSetSelection(lstP, LstGetSelection(lstP));
// Delete the old handle if it exists:
if ( oldText )
MemHandleFree( oldText );
// By returning handled = true, the OS will not
automatically
// redraw the PopTrigger label according to its
associated list
// selection. We draw the label manually in the
penUpEvent.
// That way, the Popup Trigger doesn't get a chance to
clobber
// our field text with its label.
handled = false;
}
break; // Break out of the popSelectEvent handler.
case penUpEvent:
// See if this is the penUpEvent generated after our special
// Poptrigger was used:
if ( gbTmLgClientTrigSelected )
{
//FieldType *fldP1;
// Reset this flag first thing
gbTmLgClientTrigSelected = false;
// Now it's safe to draw the field manually:
frmP = FrmGetActiveForm();
fldP = (FieldType *) FrmGetObjectPtr( frmP,
FrmGetObjectIndex( frmP,
TmLgClientLst));
FldDrawField( fldP );
// Optionally select the field. This allows the user
to
// enter a correction without having to tap on the
field
// first, since it's already selected:
FldSetSelection ( fldP, 0, StrLen( FldGetTextPtr(
fldP)));
LstSetListChoices(lst, itemList, numYears);
// Optionally drop the cursor focus in this field:
//FrmSetFocus( frmP, FrmGetObjectIndex( frmP,
TmLgClientLst ));
}
break; // Break out of penUpEvent handler.
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/