home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / pascal / 7397 < prev    next >
Encoding:
Internet Message Format  |  1992-12-12  |  2.3 KB

  1. Path: sparky!uunet!mcsun!sun4nl!wtrlnd!contrast!postmaster
  2. From: berend@contrast.wlink.nl (Berend de Boer)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Turbo Vision Keys?
  5. Message-ID: <724065276.AA00687@contrast.wlink.nl>
  6. Date: Fri, 11 Dec 1992 08:30:12
  7. Sender: postmaster@contrast.wlink.nl
  8. Lines: 63
  9.  
  10. Richard Madison wrote in a message to All:
  11.  
  12.  
  13.  RM>     My problem is that I have a screen which has 40 field to
  14.  RM> enter. I don't like that the <ENTER> key accepts all data. 
  15.  RM> I would like to be able to use the <ENTER> key to move to
  16.  RM> the next field.  I would also like to arrange the keys below
  17.  RM> to do what it says.
  18.  
  19.  RM> KEYS                WHAT IT DOES            WHAT I'D LIKE
  20.  
  21.  RM> enter              accepts data as ok       move to the next field
  22.  RM> down arrow                                  move to the next field
  23.  RM> up arrow                                    move to previous field
  24.  RM> left arrow         move left in field
  25.  RM> right arrow        move right in field
  26.  RM> esc                cancel                   accepts data
  27.  
  28.  
  29. Not so difficult, but you do, in this way, not conform to the CUA
  30. standard which is a serious drawback I think. More and more people are
  31. using CUA compliant UIs. But let's show the code:
  32.  
  33. What do you have to do?
  34.  
  35. When the enter key is pressed, it is grabbed by the default button if no
  36. view did handled it. So the first step
  37. 1) Do not use the bfDefault flag
  38. 2) Override the HandleEvent of your dialog.
  39.  
  40. procedure TMyDialog.HandleEvent(var Event : TEvent);
  41. begin
  42.   TDialog.HandleEvent(Event);          {* kbEnter key not handled *}
  43.   if (Event.What and evKeyBoard <> 0) and (Event.KeyCode = kbEnter) then
  44.     SelectNext(FALSE);
  45. end;
  46.  
  47. That's the first one.
  48.  
  49. The up, down, left and right arrow keys are not so easy. For example the
  50. left arrow key, you have to check for views at the left, and then
  51. choosing from that views the first selectable view at the left.
  52.  
  53.  
  54. The esc key is handled by the default TDialog.HandleEvent. So check for
  55. the Esc key before TDialog.HandleEvent get it:
  56.  
  57. procedure TMyDialog.HandleEvent(var Event : TEvent);
  58. begin
  59.   if (Event.What and evKeyBoard <> 0) and (Event.KeyCode = kbEsc) then  begin
  60.     Event.What := evCommand;
  61.     Event.Command := cmOK;
  62.   end;
  63.   TDialog.HandleEvent(Event);
  64. end;
  65.  
  66.  
  67. Groetjes,
  68.  
  69. Berend. (-:
  70. fido: 2:281/527.23
  71. email: berend@contrast.wlink.nl
  72.  
  73.