GEOS SDK TechDocs
|
|
2 Mouse Input
|
2.2 Gaining the Mouse Grab
Each time the user moves the mouse or clicks a mouse button, GEOS generates a mouse event and passes it to the proper object. Mouse events are actually
MetaClass
messages that any object may intercept. Default handlers for these messages typically do nothing, so if you do not handle a particular event, it will likely be ignored.
GEOS uses three basic types of mouse events: button, pointer, and drag events. Button events indicate when the user has either pressed or released any mouse button (double-clicks are considered Button events). Pointer events indicate that the mouse has been moved. Drag events indicate the user has clicked and dragged the mouse. All of these types pass information about the mouse context and the operations currently in progress.
The Input Manager checks both the button state and the mouse movement before deciding on an event's type. For example, ifthe user clicks twice quickly, the Input Manager decides whether the user intended a double-click or a click-move-click. Objects receiving the events do not have to differentiate between the two; the events automatically contain the required information.
Pointer events are fairly straightforward; when the mouse is moved, the Input Manager generates the proper
MSG_META_MOUSE_PTR
indicating the move. This message also indicates the state of the mouse buttons and keyboard modifier keys.
Button events are quite a bit more complex. With each button press or release, the Input Manager generates a
MSG_META_MOUSE_BUTTON
which gets translated into the proper press/release/drag event before being passed on to the application. The final message generated depends on which button was pressed, whether large graphics coordinates are being used, and whether the event is being sent pre-passive or post-passive.
Among Button events, there are two basic types: the press and the release. All press events are of the form
MSG_META_START_...
,
and all release events are of the form
MSG_META_END_...
. The last portion of the message name is the function of the button pressed or released. The various buttons are referred to by their meaning to the Specific UI, as follows:
SELECT
MOVE_COPY
FEATURES
OTHER
A press event indicates the user pressed down on the particular button. A release event indicates the user released the button. If the user presses a button and moves the mouse, a drag event will be sent after the initial press event. If the user double-clicks, a special flag will be sent with a single press event; it is up to the application to handle double-clicks differently.
Drag events are of the form
MSG_META_DRAG_...
, similar to Button events. Each of the above button types has a corresponding drag message. If the user presses a mouse button and quickly moves the mouse more than a specified distance, or if he holds a particular mouse button down more than a specified time, the Input Manager will send a drag event after the press event. A single release event signifies the user released the mouse button, just as with normal presses.
There is also a complete set of events used for large documents. If an object has large bounds, or if a GenView is set up to display a large content, large mouse events will be generated instead of normal mouse events. Large events take the form
MSG_META_LARGE_...
. For example, the large version of
MSG_META_MOUSE_PTR
is
MSG_META_LARGE_PTR
.
Below are listed all the standard mouse events your objects may be interested in handling. Most objects will be interested in only a small subset of these.
MSG_META_END_SELECT
MSG_META_START_MOVE_COPY
MSG_META_END_MOVE_COPY
MSG_META_START_FEATURES
MSG_META_END_FEATURES
MSG_META_START_OTHER
MSG_META_END_OTHER
MSG_META_START_OTHER
.
MSG_META_DRAG_SELECT
MSG_META_DRAG_MOVE_COPY
MSG_META_DRAG_FEATURES
MSG_META_DRAG_OTHERListed below are the large equivalents of the above messages.
MSG_META_LARGE_PTR
MSG_META_LARGE_START_SELECT
MSG_META_LARGE_END_SELECT
MSG_META_LARGE_START_MOVE_COPY
MSG_META_LARGE_END_MOVE_COPY
MSG_META_LARGE_START_FEATURES
MSG_META_LARGE_END_FEATURES
MSG_META_LARGE_START_OTHER
MSG_META_LARGE_END_OTHER
MSG_META_LARGE_DRAG_SELECT
MSG_META_LARGE_DRAG_MOVE_COPY
MSG_META_LARGE_DRAG_FEATURES
MSG_META_LARGE_DRAG_OTHER
All the normal (as opposed to large) mouse events pass and return the same values. Each event differs based on the message itself; an object knows that
MSG_META_START_SELECT
is inherently different from
MSG_META_START_MOVE_COPY
, even though they may pass the exact same values.
Each mouse event passes three items of data and one pointer to a return structure. The three parameters are listed below; the fourth, the return structure, is detailed in the next section.
xPosition
yPosition
inputState
The first two indicate the position of the mouse in the document. The third,
inputState
, consists of two bytes of flags. The first byte indicates the type of Button event and the state of the mouse buttons during the event. It is a record of type
ButtonInfo
and has seven flags:
The second byte of
inputState
is a record of
UIFunctionsActive
, which describes which of several UI functions are currently underway. The flags set in this byte are used primarily by the UI, and you will probably not have to check them. The flags allowed, however, are listed below.
One of the parameters of every mouse event is a pointer to a
MouseReturnParams
structure. This structure is passed empty; it is up to the event handler to fill it with the proper return values. The
MouseReturnParams
structure's definition is given below:
typedef struct {
word unused; /* for alignment */
MouseReturnFlags flags;
optr ptrImage;
} MouseReturnParams;
Every time you handle a mouse event, you must fill in the
flags
field. This describes how the event was handled so the UI knows whether to pass it on to another object, change the pointer image, or treat the event as having been handled. The flags you can return are
ptrImage
field (see below).If you return MRF_SET_POINTER_IMAGE, you must specify the new image to be set. An object may want to set the pointer to a new image when it is over the object's bounds or during a drag operation. For example, if the user selects a drawing tool, the tool might set the pointer to cross-hairs instead of the default arrow.
To set the pointer's image, you must return the handle and chunk handle of a chunk containing a
PointerDef
structure. Return it in the form of an optr in the
ptrImage
field of the return structure. For full information on
PointerDef
and defining pointer images, see Setting the Pointer Image
.
If you are not setting the pointer image, return a NullOptr in
ptrImage
. You do not have to return anything in the
unused
field.
GEOS SDK TechDocs
|
|
2 Mouse Input
|
2.2 Gaining the Mouse Grab