class ViewBase
ViewBase is an abstract class providing common functionality for user-defined
views. It provides facilities for handling mouse and keyboard input, for associating
the view with one or more Models, and some default
behaviour for responding to changes in a model.
ViewBase is not intended to be used directly as a base class. Usable subclasses
of ViewBase include View and GLView.
Properties
- models
- List of models being observed. Do not modify this list directly.
Use the add_model and remove_model methods to attach and
detach models.
- model
- Convenience property for when only one model is being observed. Reading
this property returns models[0] when models is not empty, otherwise
it returns None. Assigning a model to this property removes all
other models and adds it as the sole model. Assigning None to this
property removes all models.
Abstract methods
- mouse_down(event)
- Called when a mouse-down event occurs in the view. The position attribute
of the event contains the location of the click in local coordinates.
-
- key_down(event)
- Called when a key-down event occurs in the view.
- key_up(event)
- Called when a key-up event occurs in the view.
- setup_menus(menu_state)
- Called immediately before a menu is pulled down when the view is
on the message handling path. The view should use the properties of the given
menu_state object to enable all currently legal commands that it understands,
and establish the state of relevant check marks and the contents of relevant
command groups. See Setting
Up Menus for more information.
- model_changed()
- Called when an attached model's notify_view method is called
without specifying a message name. The default action is to call the
view's invalidate method.
- model_destroyed(model)
- Called when an attached model is destroyed. The default action is
to destroy the window containing this view, if any.
Note: The model parameter should only be used to identify
which model is being destroyed, if the view is observing more than one model.
Do not rely on the state of the model object that is being destroyed.
Methods
- add_model(model)
- Attaches a model to this view, so that the view will be notified of
changes to the model. This is an alternative to calling the model's add_view
method.
- remove_model(model)
- Detaches a model from this view. This is an alternative to calling
the model's remove_view method.
- track_mouse()
- Called following the receipt of a mouse-down event, returns an iterator
which yields a series of mouse-drag events as long as the mouse button is
held down, followed by a mouse-up event. The positions of all events are
reported in the view's local coordinate system. While the iterator is active,
all mouse movement events are reported, whether they occur within the view's
bounds or not, and any other user input events are ignored.
-