home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / pascal / 4977 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.6 KB

  1. Path: sparky!uunet!psinntp!bepcp!jnicholson
  2. From: jnicholson@bowker.com (Jim Nicholson)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Re: TV Focus in Dialog views
  5. Message-ID: <ky3uPB1w164w@bowker.com>
  6. Date: Fri, 21 Aug 92 10:47:55 EDT
  7. References: <10202@vice.ICO.TEK.COM>
  8. Organization: Bowker Electronic Publishing, New Providence NJ
  9. Lines: 33
  10.  
  11. bobb@vice.ICO.TEK.COM (Robert Beauchaine) writes:
  12.  
  13. >   I'm attempting to trap loss of focus events in Turbo Vision among
  14. >   views within a dialog box.  I want to validate my numerical input
  15. >   lines whenever the user moves off the focused input, either via
  16. >   the keyboard or mouse.
  17.  
  18. Rather than messing with SetState, why not override the HandleEvent method? By
  19. doing this, you can "Peek" each event, picking the ones you want.  Sort of
  20. like the following (pseudocode):
  21.  
  22.  
  23.   procedure TMyInputLine.HandleEvent(var E : TEvent);
  24.    begin
  25.       if ThisIsAKeyboardOrMouseEvent(E) then
  26.            if ThisEventWillChangeFocus(E) then
  27.               if not YourInputValidationMethodReturnsBoolean then
  28.                  ClearEvent(E);
  29.       TInputLine.HandleEvent(E);
  30.       end;
  31.  
  32. ThisISAKeyboardOrMouseEvent(E) examines E to see what caused the event.
  33.  
  34. ThisEventWillChangeFocus(E) is easy, as long as your dialog is modal.  You
  35. simply check to see what key was pressed, and trap the tab, return, and arrow
  36. keys - or, check the mouse coordinates on a mouse-click event.
  37.  
  38. You may want to add code around the ClearEvent(E) call, to put up a validation
  39. failure message (I'd suggest beeping, flashing the screen with a couple of
  40. quick palette changes, and changing the status bar.)
  41.  
  42. - Jim
  43.  
  44.