<[EMAIL PROTECTED]> wrote:
Original Article: http://www.egroups.com/list/palm-dev-forum/?start=8612
> I have 4 fields on form.  I would like to enable the shortcut ./ entrys
> common in other palm apps to make it easy to switch between fields.
> what are the character constants for these shortcuts (forward 1 field /
> back one field) and what is the best way to jump between fields?
> currently i use: FrmSetFocus(frmP, FrmGetObjectIndex(frmP, FieldID));
>
> thanks
>
> J. Jenkins

(sorry about the premature send!)

In your form event handler, you have something like this:

        switch (eventP->eType) {

        // other cases

        case keyDownEvent:
                handled = FieldMove(eventP);  // process field prev/next keys
                break;

        }

Then FieldMove looks like this:
Boolean FieldMove(EventPtr eventP) {
        FormPtr frmP;
        Word focusFldId;

// Palm OS Documentation BUG: prevFieldChr DOES NOT have commandKeyMask
set!
//      if (eventP->data.keyDown.modifiers != commandKeyMask ||
//                      eventP->data.keyDown.keyCode != 0)
//              return false;
        switch (eventP->data.keyDown.chr) {
        case prevFieldChr: // move to previouse field   
        case nextFieldChr: // move to next field        
                frmP = FrmGetActiveForm();      // get active form
                focusFldId = FrmGetFocus(frmP);
                FrmSetFocus(frmP, (focusFldId == 1) ? 3: 1);
                return true;
        }
        return false;
}

The example above works with two text fields at index 1 and 3. Since
there are only two fields, going to the next or previous field is just a
matter of going to the field without the focus!
Your actual code might be more complex, depending on the number of
fields and their indexes. You can hard code the indexes as shown here,
if you want to rely on the front to back ordering of the fields in the
form as defined in Constructor or pilrc, or you can use the code you're
already using for a more general approach.

The prevFieldChr and nextFieldChr values are defined in Chars.h


--

  John Schettino - http://members.tripod.com/schettino/
  CORBA For Dummies, AppleScript Applications, and more (Palm OS
Programming for Dummies? hmm, could be...)

Reply via email to