home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d4xx / d430 / smartfields.lha / SmartFields / Functions / field_click.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-11  |  1.3 KB  |  44 lines

  1. /***************************************
  2. *  FIELD CLICK v1.23
  3. *  © Copyright 1988 Timm Martin
  4. *  All Rights Reserved
  5. ****************************************/
  6.  
  7. #include <exec/io.h>
  8. #include <exec/types.h>
  9. #include <graphics/text.h>
  10. #include <intuition/intuition.h>
  11. #include <console/fields.h>
  12. #include <console/functions.h>
  13.  
  14. struct Field *field_click( header, mouseX, mouseY )
  15.   struct FieldHeader *header;
  16.   SHORT  mouseX, mouseY;
  17. {
  18.   struct Field *field;        /* to step thru field list */
  19.  
  20.   field = header->FirstField;
  21.   while (field) {
  22.     if (header->Window->Width  > field->Right  &&
  23.         header->Window->Height > field->Bottom &&
  24.         mouseX >= field->Left &&
  25.         mouseY >= field->Top  &&
  26.         mouseX <= field->Right  - header->Window->BorderRight  &&
  27.         mouseY <= field->Bottom - header->Window->BorderBottom &&
  28.         field->Enabled)
  29.       {
  30.       header->BufferPos = (mouseX - field->Left) /
  31.                           header->Window->IFont->tf_XSize;
  32.       if (header->BufferPos >= field->NumChars) {
  33.         if (field->NumChars + 1 == field->MaxChars)
  34.           header->BufferPos = field->NumChars - 1;
  35.         else
  36.           header->BufferPos = field->NumChars;
  37.       }
  38.       return (field);
  39.     }
  40.     field = field->NextField;
  41.   }
  42.   return (NULL);  /* didn't click in any field */
  43. }
  44.