what
イベントの種別
MODULE ClickDraw;
FROM
GraphicWindows
IMPORT
Window,
OpenGraphicWindow,
CloseGraphicWindow,
SetPen,
TurnTo,
WriteString,
Move,
IdentifyPos;
FROM
EventBase
IMPORT
mouseDown,
mouseUp,
keyDown,
Point,
EventRecord,
PushTask,
PopTask,
PollEventTasks;
VAR
wndClickDraw :Window;
blnDone :BOOLEAN;
tskMouse :INTEGER;
tskKey :INTEGER;
PROCEDURE TrackMouse(VAR recEvent :EventRecord) :BOOLEAN;
VAR
intX,intY :INTEGER;
BEGIN
IF (recEvent.what # mouseDown) & (recEvent.what # mouseUp) THEN
RETURN FALSE
END;
intX := recEvent.where.h;
intY := recEvent.where.v;
IdentifyPos(wndClickDraw,intX,intY);
SetPen(wndClickDraw,intX,intY);
WriteString(wndClickDraw,"Clicked!");
RETURN FALSE
END TrackMouse;
PROCEDURE KeyPressed(VAR recEvent :EventRecord) :BOOLEAN;
BEGIN
IF recEvent.what # keyDown THEN
RETURN FALSE
END;
blnDone := TRUE;
RETURN TRUE
END KeyPressed;
PROCEDURE WriteMessage(wndArg :Window);
BEGIN
SetPen(wndArg,125,250);
WriteString(wndArg,"ClickDraw;b")
END WriteMessage;
BEGIN
OpenGraphicWindow(wndClickDraw,50,50,300,300,"ClickDraw",WriteMessage);
tskMouse := PushTask(TrackMouse);
tskKey := PushTask(KeyPressed);
blnDone := FALSE;
REPEAT
PollEventTasks
UNTIL blnDone;
PopTask(tskKey);
PopTask(tskMouse);
CloseGraphicWindow(wndClickDraw)
END ClickDraw.
CONST
nullEvent
mouseDown
mouseUp
keyDown
keyUp
autoKey
updateEvt
diskEvt
activateEvt
networkEvt
driverEvt
app1Evt
app2Evt
app3Evt
app4Evt
TYPE
Point
EventRecord
EventHandler
PROCEDURE PushTask(EventProc :EventHandler) :Integer;
PROCEDURE PopTask(taskNum :INTEGER);
PROCEDURE PollEventTasks;
PROCEDURE GetBusyReadEvent(VAR event :EventRecord) :BOOLEAN;
VAR
wndClickDraw :Window;
blnDone :BOOLEAN;
tskMouse :INTEGER;
tskKey :INTEGER;
PROCEDURE TrackMouse(VAR recEvent :EventRecord) :BOOLEAN;
VAR
intX,intY :INTEGER;
BEGIN
IF (recEvent.what # mouseDown) & (recEvent.what # mouseUp) THEN
RETURN FALSE
END;
intX := recEvent.where.h;
intY := recEvent.where.v;
IdentifyPos(wndClickDraw,intX,intY);
SetPen(wndClickDraw,intX,intY);
WriteString(wndClickDraw,"Clicked!");
RETURN FALSE
END TrackMouse;
EventRecord = RECORD
what :INTEGER;
message :LONGINT;
when :LONGINT;
where :POINT;
modifiers :INTEGER;
END;
intX := recEvent.where.h;
intY := recEvent.where.v;
IdentifyPos(wndClickDraw,intX,intY);
SetPen(wndClickDraw,intX,intY);
WriteString(wndClickDraw,"Clicked!");
PROCEDURE KeyPressed(VAR recEvent :EventRecord) :BOOLEAN;
BEGIN
IF recEvent.what # keyDown THEN
RETURN FALSE
END;
blnDone := TRUE;
RETURN TRUE
END KeyPressed;
PROCEDURE WriteMessage(wndArg :Window);
BEGIN
SetPen(wndArg,125,250);
WriteString(wndArg,"ClickDraw;b")
END WriteMessage;
tskMouse := PushTask(TrackMouse);
tskKey := PushTask(KeyPressed);
blnDone := FALSE;
REPEAT
PollEventTasks
UNTIL blnDone;
PopTask(tskKey);
PopTask(tskMouse);