Extended or New TurboVision Objects


Q. 412 How can I use the arrow keys to change from one control to another control?
Quite an interesting patch was posted by Mark Cole in the PascalNet area TURBOVISION.PAS. Marc can be reached at 115:4400/0 (you need to be on PascalNet also to reach him). Below his original posting.

It maybe known to most people but I was recently forced to discover this trick. If you want users to be able to use the up/down arrows to move around dialog boxes as they are often used to doing in other applications you can do it in one step by overriding Application.EventError like this...

     Procedure MyApp.EventError{(VAR Event: TEvent)};
     begin
       case Event.KeyCode of
         kbDown:       if Current <> nil then
                       begin
                         Event.Keycode := kbTab;
                         Event.Command := kbTab;
                         Current^.HandleEvent(Event);
                       end;
         kbUp:         if Current <> nil then
                       begin
                         Event.Keycode := kbShiftTab;
                         Event.Command := kbShiftTab;
                         Current^.HandleEvent(Event);
                       end;

       end;
     end;
Then, if the current focussed view is one that does not interpret the down/up arrows then it will end up as an abandoned event and get changed into a TAB.

Next question


B de Boer Last modified: Tuesday 18 April 1995 - 10:20