home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Add-Ons / 4D / ComboBox 1.1.1 / src / ComboBoxListMouseDown.c < prev    next >
Encoding:
Text File  |  1996-02-23  |  3.2 KB  |  106 lines  |  [TEXT/CWIE]

  1. //---------------------------------------------------------------------------------------
  2. //
  3. //    ComboBoxListMouseDown.c -- Source for ComboBox external list window mouse handler
  4. //
  5. //    Copyright ©1995-1996, Pensacola Christian College
  6. //
  7. //    ======================================================================
  8. //    Change History
  9. //    ======================================================================
  10. //
  11. //    1.0            08/  /95        Steve Dwire
  12. //                                            Initial release
  13. //
  14. //    1.1 a1    10/26/95        Steve Dwire
  15. //                                            Make closing the List call the script
  16. //
  17. //    1.1            11/17/95        Steve Dwire
  18. //                                            Because kCallTheScript can be passed only from a user event in
  19. //                                            the main process, I can't call the script directly when the user
  20. //                                            clicks in the list window to close it.  So I'm making 
  21. //                                            ListMouseDown() post a unique keystroke (command-@, without shift)
  22. //                                            as an autoKey event.  When I get that autokeystroke, I will pass
  23. //                                            back kCallTheScript.  By making this an autoKey instead of a
  24. //                                            keyDown event, I allow a command-@ keystroke to be passed for
  25. //                                            those who have keyboards that will actually let them type one
  26. //                                            without using the shift key.
  27. //
  28. //---------------------------------------------------------------------------------------
  29.  
  30. #include <Ext4D.h>
  31. #include <QuickDraw.h>
  32. #include "ComboBoxListMouseDown.h" // Include your header here.
  33.  
  34.  
  35. //---------------------------------------------------------------------------------
  36. //
  37. // FUNCTION: ListMouseDown
  38. //
  39. //---------------------------------------------------------------------------------
  40.  
  41. void ListMouseDown(AreaHnd AreaDataHnd, EventRecord* event, WindowPtr ListWindow)
  42. {
  43.     short                offset,len,oldItem;
  44.     Cell                theCell;
  45.     ListHandle    ListHnd;
  46.     TEHandle        TextTEHnd;
  47.     Ptr                    CellTextPtr;
  48.     GrafPtr            savePort;
  49.     Point                mousePt;
  50.     
  51.     theCell.h = 0;
  52.     theCell.v = 0;
  53.     ListHnd = (*AreaDataHnd)->ListHnd;
  54.     if(LGetSelect(true,&theCell,ListHnd))
  55.     {
  56.         oldItem = theCell.v+1;
  57.         theCell.h = 0;
  58.         theCell.v = 0;
  59.     }
  60.     else
  61.         oldItem = 0;
  62.     
  63.     if(ListHnd)
  64.     {
  65.         GetPort(&savePort);
  66.         SetPort(ListWindow);
  67.         mousePt = event->where;
  68.         GlobalToLocal(&mousePt);
  69.         LClick(mousePt, 0, ListHnd);
  70.         if(event->where.h < (*AreaDataHnd)->ListRect.right-kScrollBarWidth)
  71.         {
  72.             TextTEHnd = (*AreaDataHnd)->TextTEHnd;
  73.             if(TextTEHnd)
  74.             {
  75.                 if(LGetSelect(true,&theCell,ListHnd))
  76.                 {
  77.                     LGetCellDataLocation(&offset,&len,theCell,ListHnd);
  78.                     CellTextPtr = NewPtr(len+1);
  79.                     if(!MemError())
  80.                     {
  81.                         if (theCell.v+1 != oldItem)
  82.                             (*AreaDataHnd)->Flags.Modified = true;
  83.                         TEDeactivate(TextTEHnd);
  84.                         LGetCell(CellTextPtr,&len,theCell,ListHnd);
  85.                         TESetText(CellTextPtr, (long) len, TextTEHnd);
  86.                         DisposePtr(CellTextPtr);
  87.                         TESetSelect(0,32767,TextTEHnd);
  88.                         TEActivate(TextTEHnd);
  89.                         SetPort((*AreaDataHnd)->AreaGrafPort);
  90.                         InvalRect(&(*AreaDataHnd)->AreaRect);
  91.                     }
  92.                     (*AreaDataHnd)->Flags.Open = false;
  93.                     HideWindow(ListWindow);
  94.                     //v1.1
  95.                     // changed the following line from v1.1 a1:
  96.                     //event->message = kCallTheScript;
  97.                     // into the following line:
  98.                     PostKey((unsigned long)'@',(unsigned long)cmdKey,true);
  99.                     // so that closing the list will _really_ call the script.
  100.                 }
  101.             }
  102.         }
  103.         SetPort(savePort);
  104.     }
  105. }
  106.