Mouse Routines

Restriction: The CBL_ routines within this section are not supported when CHARSET"EBCDIC" is in effect.
Note: The CBL_mouse routines do not work with the x"AF" mouse routines.

Using the Routines

The mouse is useful for applications that require users to select from a list of options or move objects around on the screen.

To use these routines, you must ensure that your system knows that you have a mouse attached.

You must hide the mouse during the execution of any ANSI ACCEPT or DISPLAY statement that operates on the area of the screen where the mouse pointer is located.

The attributes referred to in the descriptions of routines are screen attributes, not user attributes. The top left-hand corner of the screen is row 0, column 0.

Mouse Events

Whenever the mouse is moved or a button on the mouse is pressed or released, the mouse hardware causes an interrupt. The mouse device driver takes control and, depending on a mask you have set, either saves it in a queue or ignores it. This prevents events being lost if a subsequent interrupt occurs before the application has read the event. With the mouse routines, you can read the event queue and determine how many events are in the queue.

When an event is generated, a description of it is stored in a data structure called the event-data. If the mask allows (see below), this is added to the queue. The layout of event-data is:

   event-type           pic x(2) comp-x.
         event-time           pic x(4) comp-x.
         event-row            pic x(2) comp-x.
         event-col            pic x(2) comp-x.

where the parameters are:

event-type
The action (that is, change of state) that took place:
bit 7-4 reserved
bit 3 set = button 3 pressed
bit 2 set = button 2 pressed
bit 1 set = button 1 pressed
bit 0 set = mouse moved
A button release is indicated by the bit for that button changing from 1 to 0. For example, if the mouse moves and button 1 is pressed at the same time, event-type contains 3.
event-time
The time elapsed between when the event took place and some arbitrary but fixed starting time.
event-row
Gives the row in which the mouse was positioned when the event took place.
event-col
Gives the column in which the mouse was positioned when the event took place.

The Event Mask

The event mask, which you supply, tells the system which kinds of event should be queued and which ignored. It has the same structure as event-type. An event is queued only if it happens while the corresponding mask bit is on, or while another state is on whose mask bit is on. When an event-data is queued, the bit for each state is set correctly; that is, the mask does not mask them out.

For example, the operator moving the mouse generates an event if either the mask bit for "mouse moved" is off or the operator is holding down a button and the mask bit for that button is off.