<* PRAGMA LL *>An
AnyEvent.T
is an object that can hold any of the Trestle
event-time events. This object type is useful for VBT
methods that are called in response to multiple styles of user
gestures. For instance, the callback
method of a
NumericVBT
is invoked either because a user clicked on the
plus or minus button or because the user typed a carriage
return in the type-in field. The Trestle event is passed to the
callback
method as an AnyEvent.T
, and the callback
method can then use a TYPECASE
to differentiate button clicks
from carriage returns, and to retrieve the data specific to
each type of event.
The locking level is arbitrary for all procedures in this interface.
INTERFACEAnyEvent ; IMPORT VBT, Wr; TYPE T = BRANDED OBJECT END; Key = T OBJECT key: VBT.KeyRec END; Mouse = T OBJECT mouse: VBT.MouseRec END; Position = T OBJECT position: VBT.PositionRec END; Misc = T OBJECT misc: VBT.MiscRec END;
The four subtypes of AnyEvent.T
correspond to the four
event-time Trestle events: keyboard, mouse, position, and
miscellaneous.
PROCEDURE FromKey ( READONLY event: VBT.KeyRec): Key; PROCEDURE FromMouse ( READONLY event: VBT.MouseRec): Mouse; PROCEDURE FromPosition ( READONLY event: VBT.PositionRec): Position; PROCEDURE FromMisc ( READONLY event: VBT.MiscRec): Misc;
Returnevent
as an appropriate subtype ofAnyEvent.T
.
PROCEDURE TimeStamp (anyevent: T): VBT.TimeStamp;
Return the timestamp of theanyevent
. It is a checked runtime error ifanyevent
is not a proper subtype ofAnyEvent.T
.
PROCEDURE ToWr (anyevent: T; wr: Wr.T);
Put a textual representation ofanyevent
onto the writerwr
.
END AnyEvent.