PDA

View Full Version : TEvents (Apart from TNotifyEvent)



Cazax
03-21-2009, 05:02 PM
You might have wondered, that there also many others events in forms. The most used is the TNotifyEvent, specifically the event 'OnClick' used in TButtons and almost every component in SCAR (or in Delphi):

procedure Clicked(Sender : TObject);
begin
Writeln('You clicked on it!');
end;

TEvents in SCAR require predefined parameters. For example, in TNotifyEvents you use the parameter 'Sender : TObject'. A list of some TEvents in SCAR:

TNotifyEvent:
procedure NotifyEvent(Sender : TObject);

TKeyEvent:
procedure KeyEvent(Sender: TObject; var Key: Word; Shift: TShiftState);
They are used in KeyDown and KeyPress events, example:
procedure KeyIsDown(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
Writeln('You clicked the Key number: ' + IntToStr(Key) + '!');
end;
For TShiftState you can look in Delphi tutorials.

TMouseEvent:
procedure MouseEvent(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
The same goes for this...
procedure MouseClick(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Writeln('Left click = ' + BoolToStr(Button) + ', Mouse pos =' + IntToStr(X) + ' and ' + IntToStr(Y));
end;

These are some examples on how to call other TEvents in SCAR. They are just used like Button1.OnClick := @Clicked; The same goes for every event.
The parameters are filled with the event information, like in TMouseEvent you can have the X and Y coordinates. They can useful in some cases. If you want me to explain any other event, just tell me.

NiCbaZ
03-28-2009, 03:30 AM
Usefull tut, should really be in Beg or Inter sections though :/