<*PRAGMA LL*> INTERFACEATypeInVBT ;
TypeInVBT.T
is a VBT
into which the user can type a one-line
text string using ISO-Latin 1 keycodes.
A TypeInVBT
acquires the keyboard focus when the user clicks on it
with the mouse, or whenever the program directs it to by
calling TakeFocus. Whenever it acquires the keyboard focus, it also
acquires the primary selection, and primary-selects the text string in
the VBT
.
When it has the keyboard focus, the user can append to the text by
typing graphic characters, and can backspace by typing the key
labelled <X]
. Associated with every TypeInVBT is an action
procedure that is called whenever the user types
a non-graphic character (such as RETURN
).
When a TypeInVBT
it has the keyboard focus, it responds to
the following editing commands:
control-q deletes the entire text (primary selection);
control-w copies the secondary selection to the end of the text;
control-e moves the secondary selection to the end of the text;
control-r swaps the text (primary selection) with the secondary selection.
You can make the entire text string be the secondary selection by control-clicking with the mouse.
The TypeInVBT filters keystrokes through a ComposeKey.T.
IMPORT VBT, TextVBT, PaintOp, Font, ComposeKey; TYPE T <: Public; Public = TextVBT.T OBJECT METHODS (* OVERRIDES *) init( txt: TEXT := ""; halign, valign: REAL := 0.5; hmargin: REAL := 0.5; vmargin: REAL := 0.5; fnt: Font.T := Font.BuiltIn; op: PaintOp.ColorQuad := NIL; action: Proc := NIL; ref: REFANY := NIL; composer: ComposeKey.T := NIL): T END;The call
v.init(...)
initializes v
as a TypeInVBT
. This
includes initializing v
as a TextVBT
, using the first seven
arguments. The action
argument specifies v
's action procedure;
if it is non-NIL, it is called for any non-printing characters that
the user types, except for <X] and control characters. If ref
is non-NIL
, it is added to v
property set. The composer's filter
method is invoked on every keystroke; if composer is NIL, TypeInVBT
will allocate (and initialize) a new Composer. If you pass a non-NIL
value, you must take care to initialize the composer yourself.
TYPE Composer <: CPublic; CPublic = ComposeKey.T OBJECT METHODS init (v: VBT.T) END;
A Composer overrides the feedback method to change the cursor during composing.
TYPE Proc = PROCEDURE(v: T; READONLY cd: VBT.KeyRec); PROCEDURE SetAction(v: T; action: Proc); <* LL.sup = VBT.mu *>
Change the action for non-printing, non-control characters.
PROCEDURE New( txt: TEXT := ""; halign, valign: REAL := 0.5; hmargin: REAL := 0.5; vmargin: REAL := 0.5; fnt: Font.T := Font.BuiltIn; op: PaintOp.ColorQuad := NIL; action: Proc := NIL; ref: REFANY := NIL; composer: ComposeKey.T := NIL): T;
New(args)
is short forNEW(T).init(args)
.
PROCEDURE TakeFocus(v: T; t: VBT.TimeStamp): BOOLEAN;
TakeFocus(v, t) causesv
to acquire the keyboard focus and ownership of the primary selection and returnsTRUE
, or returnsFALSE
if one or both of these acquisitions failed.
PROCEDURE HasFocus(v: T): BOOLEAN;
Does v have the keyboard focus? LL = VBT.mu
END TypeInVBT.