Inherits:
::tycho::Object
-
Source File -
Contents:
public methods
- public proc
- public variables
- protected methods
- protected variables
The abstract superclass of all interactor classes. Interactors
are a mechanism originally developed in Brad Meyer's Garnet system.
The key idea is to abstract various forms of user interaction into
objects, so that a) user interaction code can be reused easily and
b) more complex interactions can be built from simpler ones. The
interactors implemented in this set of classes fulfills both of these
goals, although they are much smaller, lighter, and more numerous
than the interactors in Garnet.
Each sub-class of Interactor implements a particular kind of
user interaction. Each is based on the observation that most user
interactions can be broken into a sequence: a click, some number
of drags, and a release. Note that each of these
actions is abstract, and they do not necessarily correspond to
to physical mouse clicks, drags, and releases.
Interactors can be combined to make more complex interactions: several
interactors can be bound to the same picture; they can be
cascaded to modify each other's effects. Actions eventually
end up being given to a Picture
object, which then reacts according to its current "behavior.".
Public constructs
-
bind
tagOrID args
- ``Bind'' an interactor to a picture or to a tag. This creates a binding
to the specified picture or tag so that, when the appropriate event
occurs on that picture or a picture with the specified tags, the
interactor is ``activated'' on the target. The
options
-button
and -modifiers
determine the actual events.
By default, the mouse-press event is the one used to activate
the interactor.
Always return the bound script for this tag and options.
-
cascade
that
- Tell the interactor to forward actions to a proxy interactor
instead of directly to the target object. This is typically used
when further modification of the
interaction can be provided by another interactor -- for example,
a Stepper interactor can be used
to quantize movement within a bounded rectangular region provided by the
Bounder interactor.
With no argument, this method returns the cascaded interactor;
with a null argument, it disconnects the cascade.
-
disable
- Disable an interactor. This calls
unbind
on all bindings to
disable events, but remembers what they are so they can be
enabled again.
-
enable
- Re-enable an interactor. This calls
bind
on all bindings to
re-enable events.
-
target
args
- Set or get the picture that this interactor is currently
operating on. With no argument, return the current target;
with an argument, sets the target picture to that value. This
method is for use only within actions -- the target is not valid
until the interactor has been activated. If you're careful about it,
you can use this method to have the picture being operated on
set to a different picture to the one being moused on, which is
very useful in some situations -- see
Slider for an example.
-
unbind
tagOrID args
- Remove a binding from the interactor to a picture or a tag. The
optional arguments must be the same as they were for the
corresponding call to
bind
.
-
uncascade
- Stop forwarding actions to a proxy interactor.
-
event
type args
- Translate an event specification into a Tk event code. The arguments
take the form
type: specifies which button to use.
-button button: specifies which button to use.
-key key: specifies which key to use.
-modifiers modifiers: specifies any modifiers.
-
-activatecommand
- A script executed at the beginning of the interaction sequence. It
is typically used to set target parameters or to chain interactors.
As with all interactor scripts, this script takes four arguments:
this interactor, the target picture, and the x and y
co-ordinates. See the
apply procedure for the format of the script.
-
-deactivatecommand
- A script executed at the end of the interaction sequence. It is
useful for assigning objects created during an interaction to
variables, and other clean-up stuff.
-
-dragcommand
- A script executed at the completion of the interactor's drag
method. This is useful for performing some actions on
an object when it is moved, etc.
Protected constructs
-
activate
t x y args
- Abstract method.
Make this interactor active. That is, set up bindings to intercept
events that I need from now on. One of the bindings is obliged to
call
deactivate
to remove the bindings.
-
click
x y args
- Start an interaction sequence. The co-ordinates x and y
are the current mouse coordinates relative to the slate.
By default, this method simply forwards a
click
action
to the target, or to the proxy interactor if there
is one. Sub-classes that over-ride this method should always call
this implementation to forward the click action.
-
continue
- Continue an interaction sequence. This method is intended for a few
special kinds of interaction that use different buttons to mark
different ``phases'' of the interation. It is still very experimental.
-
deactivate
args
- Abstract method.
Make this interactor inactive. In other words, remove my bindings.
-
drag
x y
- Continue an interaction sequence with a mouse move. The co-ordinates
x and y are the current mouse coordinates relative to
the slate. By default, this method simply forwards a
drag
action to the target, or to the proxy interactor if there
is one. Sub-classes that over-ride this method should always call
this implementation to forward the drag action.
-
execute
script {x {}} {y {}} {options {}}
- Execute a script, by applying it to the interactor, the target, and
the current x and y coordinates.
-
proxy
args
- Set or get the interactor to which actions
are forwarded. If null, actions are sent straight to the target.
-
release
- Terminate an interaction sequence. By default, this method
simply forwards a
release
action to the target, or to the proxy interactor if there
is one. Sub-classes that over-ride this method should always call
this implementation to forward the release action.
-
bindings
- The tags or pictures to which this picture has been bound and arguments.
-
canvas
- The canvas on which this interactor resides.
-
slate
- The slate on which this interactor resides.
-
target
- The picture that this interactor is currently operating on.
-
proxy
- An interactor to forward actions to.
Index of classes
Author: H. John Reekie
Version: @(#)Interactor.itcl 1.19 12/16/96
Copyright: (c) 1996 The Regents of the University of California.