mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-12-05 08:27:17 +01:00
+ Initial implementation
This commit is contained in:
parent
ac0bddc6c1
commit
f9339d5362
9
docs/mouseex/README
Normal file
9
docs/mouseex/README
Normal file
@ -0,0 +1,9 @@
|
||||
This directory contains the examples for the mouse unit.
|
||||
|
||||
ex1.pp contains an example of the DetectMouse function.
|
||||
ex2.pp contains an example of the GetMouseButtons function.
|
||||
ex3.pp contains an example of the GetMouseEvent function.
|
||||
ex4.pp contains an example of the GetMouseX,GetMouseY functions.
|
||||
ex5.pp contains an example of the HideMouse,ShowMouse functions.
|
||||
ex6.pp contains an example of the PollMouseEvent function.
|
||||
ex7.pp contains an example of the SetMouseXY function.
|
||||
18
docs/mouseex/ex1.pp
Normal file
18
docs/mouseex/ex1.pp
Normal file
@ -0,0 +1,18 @@
|
||||
Program Example1;
|
||||
|
||||
{ Program to demonstrate the DetectMouse function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
Var
|
||||
Buttons : Byte;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
Buttons:=DetectMouse;
|
||||
If Buttons=0 then
|
||||
Writeln('No mouse present.')
|
||||
else
|
||||
Writeln('Found mouse with ',Buttons,' buttons.');
|
||||
DoneMouse;
|
||||
end.
|
||||
12
docs/mouseex/ex2.pp
Normal file
12
docs/mouseex/ex2.pp
Normal file
@ -0,0 +1,12 @@
|
||||
Program Example2;
|
||||
|
||||
{ Program to demonstrate the GetMouseButtons function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
Writeln('Press right mouse button to exit program');
|
||||
While (GetMouseButtons<>MouseRightButton) do ;
|
||||
DoneMouse;
|
||||
end.
|
||||
37
docs/mouseex/ex3.pp
Normal file
37
docs/mouseex/ex3.pp
Normal file
@ -0,0 +1,37 @@
|
||||
Program Example3;
|
||||
|
||||
{ Program to demonstrate the GetMouseEvent function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
|
||||
Var
|
||||
Event : TMouseEvent;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
Writeln('Play with mouse. Press right mouse button to end.');
|
||||
Repeat
|
||||
GetMouseEvent(Event);
|
||||
With event do
|
||||
begin
|
||||
Write('Action:');
|
||||
Case Action of
|
||||
MouseActionDown : Write('Mouse down.');
|
||||
MouseActionUp : Write('Mouse up.');
|
||||
MouseActionMove : Write('Mouse move.');
|
||||
end;
|
||||
Writeln('Button state : ');
|
||||
If (Buttons and MouseLeftbutton)<>0 then
|
||||
Write('Left ');
|
||||
If (Buttons and MouseRightbutton)<>0 then
|
||||
Write('Right ');
|
||||
If (Buttons and MouseMiddlebutton)<>0 then
|
||||
Write('Middle ');
|
||||
Write('Button(s)');
|
||||
Writeln(' at ',X,',',Y,'.');
|
||||
end;
|
||||
Until (Event.Buttons=MouseRightButton) and
|
||||
(Event.Action=MouseActionDown);
|
||||
DoneMouse;
|
||||
end.
|
||||
19
docs/mouseex/ex4.pp
Normal file
19
docs/mouseex/ex4.pp
Normal file
@ -0,0 +1,19 @@
|
||||
Program Example4;
|
||||
|
||||
{ Program to demonstrate the GetMouseX,GetMouseY functions. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
Var
|
||||
X,Y : Word;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
Writeln('Move mouse cursor to square 10,10 to end');
|
||||
Repeat
|
||||
X:=GetMouseX;
|
||||
Y:=GetMouseY;
|
||||
Writeln('X,Y= (',X,',',Y,')');
|
||||
Until (X=9) and (Y=9);
|
||||
DoneMouse;
|
||||
end.
|
||||
31
docs/mouseex/ex5.pp
Normal file
31
docs/mouseex/ex5.pp
Normal file
@ -0,0 +1,31 @@
|
||||
Program Example5;
|
||||
|
||||
{ Program to demonstrate the HideMouse function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
Var
|
||||
Event : TMouseEvent;
|
||||
Visible: Boolean;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
ShowMouse;
|
||||
Visible:=True;
|
||||
Writeln('Press left mouse button to hide/show, right button quits');
|
||||
Repeat
|
||||
GetMouseEvent(Event);
|
||||
With Event do
|
||||
If (Buttons=MouseLeftbutton) and
|
||||
(Action=MouseActionDown) then
|
||||
begin
|
||||
If Visible then
|
||||
HideMouse
|
||||
else
|
||||
ShowMouse;
|
||||
Visible:=Not Visible;
|
||||
end;
|
||||
Until (Event.Buttons=MouseRightButton) and
|
||||
(Event.Action=MouseActionDown);
|
||||
DoneMouse;
|
||||
end.
|
||||
44
docs/mouseex/ex6.pp
Normal file
44
docs/mouseex/ex6.pp
Normal file
@ -0,0 +1,44 @@
|
||||
Program Example6;
|
||||
|
||||
{ Program to demonstrate the PollMouseEvent function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
Procedure DumpEvent(Const Event : TMouseEvent);
|
||||
|
||||
begin
|
||||
With event do
|
||||
begin
|
||||
Write('Action:');
|
||||
Case Action of
|
||||
MouseActionDown : Write('Mouse down.');
|
||||
MouseActionUp : Write('Mouse up.');
|
||||
MouseActionMove : Write('Mouse move.');
|
||||
end;
|
||||
Writeln('Button state : ');
|
||||
If (Buttons and MouseLeftbutton)<>0 then
|
||||
Write('Left ');
|
||||
If (Buttons and MouseRightbutton)<>0 then
|
||||
Write('Right ');
|
||||
If (Buttons and MouseMiddlebutton)<>0 then
|
||||
Write('Middle ');
|
||||
Write('Button(s)');
|
||||
Writeln(' at ',X,',',Y,'.');
|
||||
end;
|
||||
end;
|
||||
|
||||
Var
|
||||
Event : TMouseEvent;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
Writeln('Play with mouse. Press right mouse button to end.');
|
||||
Repeat
|
||||
If PollMouseEvent(Event)Then
|
||||
DumpEvent(Event)
|
||||
else
|
||||
Write('.');
|
||||
Until (Event.Buttons=MouseRightButton) and
|
||||
(Event.Action=MouseActionDown);
|
||||
DoneMouse;
|
||||
end.
|
||||
23
docs/mouseex/ex7.pp
Normal file
23
docs/mouseex/ex7.pp
Normal file
@ -0,0 +1,23 @@
|
||||
Program Example7;
|
||||
|
||||
{ Program to demonstrate the SetMouseXY function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
Var
|
||||
Event : TMouseEvent;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
Writeln('Click right mouse button to quit.');
|
||||
SetMouseXY(40,12);
|
||||
Repeat
|
||||
If (GetMouseX>70) then
|
||||
SetMouseXY(10,GetMouseY);
|
||||
If (GetMouseY>20) then
|
||||
SetMouseXY(GetMouseX,5);
|
||||
GetMouseEvent(Event);
|
||||
Until (Event.Buttons=MouseLeftButton) and
|
||||
(Event.Action=MouseActionDown);
|
||||
DoneMouse;
|
||||
end.
|
||||
8
docs/mouseex/newex
Normal file
8
docs/mouseex/newex
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
if [ -e ex${1}.pp ]; then
|
||||
mv ex${1}.pp ex${1}.pp.orig
|
||||
fi
|
||||
sed -e s/Example/Example$1/ -e s/\\\*\\\*\\\*/$2/ <template.pp >ex${1}.pp
|
||||
echo "ex${1}.pp contains an example of the $2 function." >>README
|
||||
joe ex${1}.pp
|
||||
ppc386 ex${1}.pp && ex${1}
|
||||
10
docs/mouseex/template.pp
Normal file
10
docs/mouseex/template.pp
Normal file
@ -0,0 +1,10 @@
|
||||
Program Example;
|
||||
|
||||
{ Program to demonstrate the *** function. }
|
||||
|
||||
Uses mouse;
|
||||
|
||||
begin
|
||||
InitMouse;
|
||||
DoneMouse;
|
||||
end.
|
||||
Loading…
Reference in New Issue
Block a user