home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 13239 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  2.2 KB

  1. Path: sparky!uunet!munnari.oz.au!goanna!sheoak!redgum.ucnv.edu.au!i925936
  2. From: i925936@redgum.bcae.oz.au (-The Shadow-)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Simple Problem
  5. Message-ID: <1897@sheoak.bcae.oz.au>
  6. Date: 31 Jul 92 01:55:11 GMT
  7. Sender: news@sheoak.bcae.oz.au
  8. Organization: UCNV, Bendigo, Victoria, Australia
  9. Lines: 79
  10. Originator: i925936@redgum.ucnv.edu.au
  11.  
  12. Here is a simple problem which I can't find the solution to. I have only
  13. just started with programming the mac toolbox so I don't know *too* much
  14. yet. The problem is that the program I am writing will not detect a
  15. mousedown event. Below is a listing of the program condensed to
  16. determine a mousedown event. 
  17.    In the form below, it will not quit until
  18. doquit is true. I know that I have not set doquit to true anywhere but
  19. as I said, the program is condensed.
  20.  
  21. Program whatever;
  22.  
  23. type eventrecord = record
  24.        what : integer;
  25.        message : longint;
  26.        when : longint;
  27.        where : point;
  28.        modifiers : integer;
  29.      end;
  30.  
  31.  
  32. const nullevent = 0;
  33.       mousedown = 1;
  34.       mouseup = 2;
  35.       mdownmask = $0002;
  36.       mupmask = $0004;
  37.       everyevent = $FFFF;
  38.  
  39. var theevent : eventrecord;
  40.  
  41. procedure initialise;
  42. var themask : integer;
  43.  
  44. begin
  45.      doquit := false;
  46.      themask := everyevent - keyupmask - mupmask;
  47.      seteventmask(themask);
  48.      flushevents(everyevent, 0);
  49.      setcursor(arrow);
  50. end;
  51.  
  52. function getnextevent(mask : integer; var theevent : eventrecord):
  53. boolean;
  54. begin
  55. end;
  56.  
  57. procedure doevent;
  58. begin
  59.      if getnextevent(everyevent, theevent then
  60.        case theevent.what of
  61.           mousedown : domousedown;
  62.        end;
  63. end;
  64.  
  65. procedure mainloop;
  66. begin
  67.      systemtask;
  68.      doevent;
  69. end;
  70.  
  71. begin
  72.     initialise;
  73.     repeat
  74.           mainloop;
  75.     until doquit;
  76. end.
  77.  
  78.  
  79. There are probably a heap of problems in this program but I can't work
  80. out what they are. The mask of the event keeps returning a value of -1
  81. too and getnextevent returns a true value.
  82.  Is there a better way to set up the function getnextevent as well?
  83.  
  84. Anyway, somebody out there should know the answer to this. Please reply
  85. by either email at i925936@redgum.ucnv.edu.au or by this newsgroup
  86. because it took *ages* to write this out!
  87.   BTW, the program is written in THINK Pascal version 4.0
  88.  
  89. Thanx, 
  90.        Richard.
  91.