| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (7 out of 17)

Configuring Mouse Clicks

These clauses declare an association between a keystroke or a mouse click, and a low-level G2 operation or user menu choice. A mouse click means pressing or releasing a mouse button. When the user displays the Help screen (by typing Control + /) the Help information describes any mouse-click associations currently in effect.

Clause Purpose
selecting ... implies
Associates selecting an item of the specified class (or classes) with a system-defined menu choice, a user-menu-choice, or a null operation.
pressing ... implies
Associates pressing a mouse button with a system-defined menu choice, a user-menu-choice, or a system-defined non-menu operation.
releasing ... implies
Associates releasing a mouse button with a system-defined menu choice, a user-menu-choice, or a non-menu operation.
pressing ... on ... starts
Invokes a procedure that tracks movement of the mouse, to support state-based operations such as drag-and-drop.


Note: You cannot use configurations to associate certain mouse clicks that are intercepted by your platform's window manager. For example, the Alt-mouse-down user gesture is meaningful for the HP-Vue window manager on Hewlett-Packard 900 series workstations.

Associating Selection with a Menu Choice or User Menu Choice

Use the selecting ... implies clause to configure selection operations that apply to one item.

Selection means the pair of mouse clicks, mouse-down and mouse-up, which occur in order over the same item.

For example, the following configuration statement associates the system-defined create-subworkspace operation with selecting an item of the CONVEYOR-STATION class:


Tip: You should differentiate between the selecting ... implies clause, which is appropriate for configuring operations directed at one item, such as create-by-cloning, and the typing ... implies clause, which is appropriate for configuring operations not directed at any particular item, such as save-KB.

You can also specify a selecting ... absolutely implies clause to override all other configurations that use a selecting ... implies clause for the specified class in the same hierarchy. G2 resolves configurations in the same hierarchy with selecting ... absolutely implies clauses that conflict according to G2's precedence rules for configurations.

For example, the following configuration statement, which associates the system-defined go-to-subworkspace operation with selecting an item of the NAVIGATE-DOWN-BUTTON class, overrides any other conflicting configurations in the configured item's hierarchy:


Note: A selecting ... implies clause always overrides a menu choices for clause for the same target item identified by class.

Associating a Mouse Click with an Operation

Use the pressing ... implies clause to associate a mouse-down event with an operation:

Use the releasing ... implies clause to associate a mouse-up event with an operation:


Tip: If you must configure both the mouse-down and mouse-up events for a particular item (or for any item of a particular class), use the pressing ... on ... starts clause, as described in the section
Associating a Mouse Click with a Mouse-Tracking Procedure.

You can associate the mouse-down or mouse-up events with an operation that is targeted on:

In the Text Editor, when you specify the pressing ... implies clause or the releasing ... implies clause, G2 prompts you to enter the name of a user menu choice, or to select from a list of system-defined menu choices, system-defined workspace-oriented operations, and system-defined KB-wide operations.

Associating a Mouse Click with Drag and Drop Capabilities

You can configure a class of items or an instance to permit copying or transferring. The two available clauses for configuring items are:

Configuration clause: Description:
ole-clone
Permits the item to be cloned for dragging to a location in the current KB, or to another G2 or Telewindows process.
ole-transfer
Permits the item to be transferred by simply dragging to a new location in the current KB, or to another G2 or Telewindows process.

You can configure items for drag and drop capabilities with:

For example, to use only a mouse event for cloning an item, enter a statement such as:

We recommend using the combination of a modifier key and a mouse button to permit multiple events upon a single item, as in the next example.

To configure an item for cloning or transferring with a combination of a modifier key and a mouse button, use a statement such as:

Associating a Mouse Click with a Mouse-Tracking Procedure

Use the pressing ... on ... starts clause to declare that mouse clicks on items of one or more classes cause G2 to call a user-defined mouse-tracking procedure. You code this procedure to respond to a change in the mouse pointer's location within a particular window, until the next mouse-click event within that window.

This allows your KB to support state-based, user-interface operations, including drag-and-drop operations such as a simple drawing command and opening and selecting from pulldown menus.

For example, you can code a phrase like this:

This phrase causes G2 to call the track-mouse-over-custom-object procedure after the user depresses any mouse button over any custom-object, and to call that procedure again each time the mouse pointer passes over any other item in G2's own window.

You can also code a phrase like this:

This phrase causes G2 to call the track-mouse-over-custom-object procedure after the user simultaneously depresses Control and any mouse button over any custom-object; to call that procedure again each time the workstation's window manager updates the mouse position; and to call the procedure again each time the mouse pointer passes over any other item in G2's own window.

In a pressing ... on ... starts clause you can configure these mouse-click-events:

The clause must also refer to:


Note: You cannot specify an item of the METHOD or METHOD-DECLARATION class as the mouse-tracking-procedure. However, your mouse-tracking procedure can call or start a method.

Coding the Mouse-Tracking Procedure

Your mouse-tracking procedure must conform to this procedure signature:

You must code your mouse-tracking procedure to respond to these events:

When the configured mouse-click-event occurs over any trigger-class item, G2 automatically calls the mouse-tracking-procedure, the first time, and passes to it:


Note: G2 does not call the mouse-tracking procedure if a mouse-click event occurs over a disabled item.

For each tracked-class item onto which the mouse pointer passes, G2 automatically calls the mouse-tracking-procedure again, and passes to it:

For each tracked-class item from which the mouse pointer passes, G2 automatically calls the mouse-tracking-procedure again, and passes to it:

When the user releases the mouse button, G2 automatically calls the mouse-tracking-procedure again, and passes to it:

If the configuration specifies the phrase continuously over, then for each tracked-item over which the mouse pointer passes, G2 automatically calls the mouse-tracking-procedure each time the workstation's window manager updates the mouse position. When G2 calls the mouse-tracking-procedure, G2 passes to it:

Example of Mouse-Tracking Procedure

For example, suppose you have a PULL-DOWN-MENU class, whose instances are related to instances of the PULL-DOWN-MENU-CHOICE class. You can use a configuration statement with a pressing ... on ... starts clause, as follows, to implement operations that support selection of pulldown menu choices:

Including this pressing ... on ... starts clause in the configuration requires that you write a procedure named use-pull-down-menu, as follows:

In this sample procedure, notice that:


Note: If the mouse button is released over the tracked-window's background tiling pattern, G2 supplies the g2-window that is associated with this process window (belonging to G2 or Telewindows) as the value for tracked-item and returns x-mouse-position and y-mouse-position as zero (0).

If tracked-item was deleted during mouse-tracking, trigger-item is passed as the value false for all subsequent mouse-tracking events.

If tracked-item was deleted between when G2 detects the ENTER and LEAVE events, the tracked-item argument has the value false for the LEAVE event.

Conflicts Between Mouse-Tracking and Other User Interface Operations

Other user-interface operations can also occur after mouse-tracking has begun and before mouse-tracking ends. For example, the KB's processing can perform a transfer ... to the mouse action after mouse-tracking processing has begun; after the user executes mouse-down to drop the item, the mouse-tracking processing resumes.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (7 out of 17)

Copyright © 1997 Gensym Corporation, Inc.