Programming Guide


Mouse Events, Activation, and Dragging

   

This section discusses how your part should respond to mouse-down, mouse-up, and activate events in order to activate your part or your window, initiate a dragging operation, or create a selection. Your HandleEvent method (see "HandleEvent Method of Your Part Editor") should dispatch events to routines that perform the actions described here. For other information about creating and modifying selections, see "Mouse-Down Tracking and Selection".

How Part Activation Occurs

   

A part's frame activates itself in these situations:

The part activates itself by acquiring the selection focus (see "Focus Types") for one of its display frames. The part is then responsible for displaying its contents appropriately (such as by restoring the highlighting of a selection) and for providing any menus, controls, palettes, floating windows, or other auxiliary items that are part of its active state. The part must also obtain ownership of any other focuses that it needs. OpenDoc draws the active frame border around the frame with the selection focus. Figure 49 illustrates some of the visual changes caused by activation.

Figure 49. Inactive and Active States of a Part



View figure.

 

In Figure 49, the graphics part is active. OpenDoc draws the active frame border around its frame.

Typically, one part is deactivated when another is activated. A part is expected to deactivate itself when it receives a request to relinquish the selection focus, plus, possibly, other focuses. The deactivating part is responsible for clearing its selections and for removing any menus and other items that were part of its active state.

Note:

An active part in the active window should not maintain a background selection.
OpenDoc removes the active frame border from around the (now inactive) part and draws it around the part that currently has the selection focus.

Mouse events that cause part activation can also cause window activation and can lead to dragging of part content. Figure 50 illustrates elements you must consider in handling mouse-down events. Your part should handle mouse events according to:

Figure 50. Elements Related to Mouse Events in Active and Inactive Windows



View figure.

Note these points from the previous figure:

The event-handling guidelines given here are designed to provide the user with maximum consistency and flexibility when activating parts and when dragging selections.

Handling Mouse Events

Mouse events are typically sent to your part's HandleEvent method as normal mouse messages for your operating system. Events in embedded frame or its border may be converted into synthetic OpenDoc events such as kODEvtMouseDownEmbedded of kODEvtMouseDownBorder events. For converted events, the /BEGIN-ITALICS/ originalType /END-ITALICS/ field of the EventInfo structure will contain the event type of the original mouse message.

Handling Activate Events

As noted in "Activate Events", your part receives an activate event for each of its facets when your window becomes active, and a deactivate event when your window becomes inactive.

When a window becomes inactive, the part that holds the selection focus is likely to relinquish that focus (on request by another part) but can still maintain, as a background selection, any selection it had been displaying. Conversely, when a window becomes active, the part that had held the selection focus when the window became inactive normally regains the selection focus. That part may or may not be the part that actually activated the window.

This part-activation convention requires that your part respond to activate and deactivate events by recording or retrieving stored information on its focus transfers; see "Window Activation" for more information.

Activate events in a window go first to the most deeply embedded facets and last to the root facet. This dispatch order gives the root part the opportunity to obtain the selection focus if no embedded part has done so. It also allows the root part to override any activation actions taken by embedded parts.


[ Top | Previous | Next | Contents | Index | Documentation Homepage ]