home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_PAS
/
KEYCTRL.ZIP
/
KEYCTRL.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1994-01-07
|
4KB
|
171 lines
Unit KeyCtrl;
{$F+,O+,A-}
{Written By Paul Backus 1994,
Schippersdreef 44c
6216 TL Maastricht
Telf. 31,043-433872
CopyRights (c) 1994
Compuserve 73064,2473
The sources may be used as is on your own risk.
KeyCtrl is a Simple Demo of how to jump from field to field
by using the cursor keys instead of the tab key. It also works
for the Pushbuttons. Its also gives you an example of how to control
a pushbutton by modifying the state of the radiobutton.
Please Let me Know
- if you find other possibilities.
- what you think of the keyCtrl.
GoodLuck.
}
interface
Uses App, Dialogs, Drivers, Objects, Views, MsgBox;
Type
PMyInputLine=^TmyInputLine;
TMyInputLine=Object (TInputLine)
Procedure handleevent(var event:Tevent); Virtual;
end;
PMyButton=^TMyButton;
TMyButton=object (TButton)
procedure handleevent(var event:Tevent); Virtual;
end;
PHorizontalButtons=^THorizontalButtons;
THorizontalButtons=Object(TRadioButtons)
PtrButton : PMyButton;
procedure handleevent(var event:Tevent); Virtual;
end;
PVerticalButtons=^TVerticalButtons;
TVerticalButtons=Object(TRadioButtons)
PtrButton : PMyButton;
procedure handleevent(var event:Tevent); Virtual;
end;
implementation
{TMyInputLine}
Procedure TMyInputLine.handleevent(var Event:Tevent);
begin
if event.what=evnothing then exit;
inherited handleevent(event);
if state and sffocused<>0 then
if event.what=evkeydown then
case event.keycode of
kbdown :
begin
owner^.selectnext(false);
clearevent(event);
end;
kbup :
begin
owner^.selectnext(true);
clearevent(event);
end;
end;
end;
{TMybutton PB!!}
procedure TMyButton.HandleEvent(var Event: TEvent);
begin
inherited handleevent(event);
if event.what=evkeydown then
if state and sffocused <>0 then
case event.keycode of {PB!!}
kbdown ,
kbright :
begin
owner^.focusnext(false);
clearevent(event);
end;
kbup ,
kbleft :
begin
owner^.focusnext(true);
clearevent(event);
end;
end;
end;
{THorizontalButton PB!!}
Procedure THorizontalButtons.HandleEvent(Var Event:Tevent);
var SaveValue:Word;
begin
SaveValue:=Value;
if state and sffocused<>0 then
if event.what=evkeydown then
case event.keycode of
kbdown :
begin
owner^.selectnext(false);
clearevent(event);
end;
kbup :
begin
owner^.selectnext(true);
clearevent(event);
end;
end;
inherited handleevent(event);
if state and sffocused<>0 then
begin
if PtrButton<>nil then
if saveValue<>Value then
begin
if value = 1 then disablecommands([ptrbutton^.command]);
if value = 0 then enablecommands([ptrbutton^.command]);
end;
end;
end;
{TVerticalButton PB!!}
Procedure TVerticalButtons.HandleEvent(Var Event:Tevent);
var SaveValue:Word;
begin
SaveValue:=Value;
if state and sffocused<>0 then
if event.what=evkeydown then
case event.keycode of
kbleft :
begin
owner^.selectnext(true);
clearevent(event);
end;
kbright :
begin
owner^.selectnext(false);
clearevent(event);
end;
end;
inherited handleevent(event);
if state and sffocused<>0 then
begin
if PtrButton<>nil then
if saveValue<>Value then
begin
if value = 1 then disablecommands([ptrbutton^.command]);
if value = 0 then enablecommands([ptrbutton^.command]);
end;
end;
end;
end.