2 Replies Latest reply: Oct 1, 2008 10:13 AM by andrejusc RSS

    Need your help on sADMItem->SetTrackProc usage

    andrejusc Community Member
      Hi,

      I'm trying to implement very simple thing. I have a dialog with an edit field, in which user enters some digit(s). While he/she enters them - I want to update another field based on input.

      For initial field I have this part of code in dialog Init:

      item = sADMDialog->GetItem(dialog, IDC_FIELDONE);
      if (item != NULL) {
      sADMItem->SetUnits(item, kADMNoUnits);
      sADMItem->SetIntValue(item, 1);
      sADMItem->SetTrackProc(item, FieldTrackHandler);
      }

      and that FieldTrackHandler has such beginning:

      static ASBoolean FieldTrackHandler(ADMItemRef item, ADMTrackerRef tracker)
      {
      sADMItem->DefaultTrack(item, tracker);
      ADMDialogRef dialog = sADMItem->GetDialog(item);

      ADMAction thisAction = sADMTracker->GetAction(tracker);
      if (thisAction == kADMKeyStrokeAction) {
      ASInt32 enteredNum = 0;
      ADMItemRef eNum = sADMDialog->GetItem(dialog, IDC_FIELDONE);
      if (eNum != NULL)
      enteredNum = sADMItem->GetIntValue(eNum);

      ...skipped here while doing something with another field...

      Now, when I press some digit and check that enteredNum value - I always get in it old value, i.e. which was before inside that edit box. Do I need to do some other sequence of calls or place that DefaultTrack somewhere else? I assume from my test that my FieldTrackHandler is called before a value actually reaches that edit control, but then how could I catch that new updated value?

      Any help would be appreciated.
        • 1. Re: Need your help on sADMItem->SetTrackProc usage
          Polda1 Community Member
          Hi,
          I strongly recommend not to invest your time in ADM any more.

          However, solution to your problem is to use ADM notifiers instead of Tracks.

          Attatch ADM Notifier to your field:
          sADMItem->SetNotifyProc(sADMDialog->GetItem(YourDialog, IDC), YourNotifierFunc);

          and when the YourNotifierFunc is called, check the type:

          if( (sADMNotifier->IsNotifierType(inNotifier, kADMIntermediateChangedNotifier)) ) ...

          You get better results with that.

          Polda
          • 2. Re: Need your help on sADMItem->SetTrackProc usage
            andrejusc Community Member
            Hi Polda,

            I was albe to solve my issue with Track handler in such way inside its procedure:

            ADMAction thisAction = sADMTracker->GetAction(tracker);
            if (thisAction == kADMKeyStrokeAction) {
            char str[256];
            sADMItem->GetText(item, str, sizeof(str)*sizeof(char));
            ...

            It works for me like a charm.