home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!psinntp!bepcp!jnicholson
- From: jnicholson@bowker.com (Jim Nicholson)
- Newsgroups: comp.lang.pascal
- Subject: Re: TV Focus in Dialog views
- Message-ID: <ky3uPB1w164w@bowker.com>
- Date: Fri, 21 Aug 92 10:47:55 EDT
- References: <10202@vice.ICO.TEK.COM>
- Organization: Bowker Electronic Publishing, New Providence NJ
- Lines: 33
-
- bobb@vice.ICO.TEK.COM (Robert Beauchaine) writes:
-
- > I'm attempting to trap loss of focus events in Turbo Vision among
- > views within a dialog box. I want to validate my numerical input
- > lines whenever the user moves off the focused input, either via
- > the keyboard or mouse.
-
- Rather than messing with SetState, why not override the HandleEvent method? By
- doing this, you can "Peek" each event, picking the ones you want. Sort of
- like the following (pseudocode):
-
-
- procedure TMyInputLine.HandleEvent(var E : TEvent);
- begin
- if ThisIsAKeyboardOrMouseEvent(E) then
- if ThisEventWillChangeFocus(E) then
- if not YourInputValidationMethodReturnsBoolean then
- ClearEvent(E);
- TInputLine.HandleEvent(E);
- end;
-
- ThisISAKeyboardOrMouseEvent(E) examines E to see what caused the event.
-
- ThisEventWillChangeFocus(E) is easy, as long as your dialog is modal. You
- simply check to see what key was pressed, and trap the tab, return, and arrow
- keys - or, check the mouse coordinates on a mouse-click event.
-
- You may want to add code around the ClearEvent(E) call, to put up a validation
- failure message (I'd suggest beeping, flashing the screen with a couple of
- quick palette changes, and changing the status bar.)
-
- - Jim
-
-