Mouse control

Subroutine

Function

PIX.MOUSE.AVAILABLE

Detect a mouse driver

PIX.MOUSE.ON

Activate a mouse

PIX.MOUSE.RESPONSE

Turn on mouse event reporting

PIX.MOUSE.OFF

Turn off mouse event reporting

PIX.MOUSE.TEST

Mouse test program

Detect a mouse driver

PIX.MOUSE.AVAILABLE is a BASIC subroutine that can be called from your applications as follows:

CALL PIX.MOUSE.AVAILABLE(AVAILABLE)

This program returns a 1 or 0 value in the variable AVAILABLE, depending upon whether HostAccess can detect that a MOUSE driver has been loaded on the PC. 1 is always returned in HostAccess.

Activate a mouse

PIX.MOUSE.ON is a BASIC subroutine that can be called from your applications as follows:

CALL PIX.MOUSE.ON(MONITOR.MOUSE.EVENTS)

This program activates the MOUSE on the PC for use with HOST applications. Turning on the mouse still allows keyboard input through. Applications can detect if the mouse has been pressed by checking for an STX followed by the text  'MS' followed by carriage return. If any other input comes through the input buffer then it can be processed in the normal way.

This program does not return the response type from the mouse, it only activates it. There is a program called PIX.MOUSE.RESPONSE that can be called but you may wish to integrate the logic around your own INPUT statements.

MONITOR.MOUSE.EVENTS, should be a string containing the words, LEFT, RIGHT, CENTRE, ALL and/or CONTINUOUS. This tells HostAccess that when any of the specified MOUSE buttons have been depressed, a response should be sent to the HOST. You can specify any or all of the options in the string using comma delimiters, e.g. if MONITOR.MOUSE.EVENTS contains "LEFT,CENTRE" then HostAccess will not send a response if the RIGHT button is clicked but will if the left or center ones are pressed.

Passing the CONTINUOUS parameter causes HostAccess to send a response back to the host every time the MOUSE is moved while one of the specified mouse buttons is depressed. This can be used by applications that need to know where the MOUSE is at any given time. This should be used with caution since a large number of inputs will occur while the mouse button is held down.

Turn on mouse event reporting

PIX.MOUSE.RESPONSE is a BASIC subroutine that can be called from your applications as follows:

CALL PIX.MOUSE.RESPONSE(RESPONSE, BUTTON, XCORD, YCORD)

This program will return the response from the mouse when one of the selected buttons has been pressed or if the button is being continuously held down. These options are selectable when turning on the MOUSE, see Activate a mouse.

To match most PICK systems, this routine will subtract 1 from the X and Y co-ordinates, i.e. assuming start row/col is 0,0.

The following subroutine parameters need to be passed or will be returned accordingly:

RESPONSE Contains the text string as input by the user, if the mouse was not used. RESPONSE will be NULL if MOUSE used, otherwise keyboard input.

BUTTON

 

 

 

 

 

 

 

 

Button will return a code from 0 to 7 which have the following meaning:

0 Button(s) released. - Only if continuously monitoring the mouse button, does this value get returned. It is only returned when any or all of the buttons are released.

1 Left Button depressed.

2 Right Button depressed.

3 Left and Right Buttons depressed.

4 Center button depressed.

5 Left and Center buttons depressed.

6 Right and Center buttons depressed.

7 Left and Right and Center buttons depressed.

In most cases, your calling routine just needs to check for a negative BUTTON variable to ensure detecting that the MOUSE has not been used.

If BUTTON is -1 then the user must have pressed return from the keyboard and thus no MOUSE response will be valid.

XCORD, YCORD

Will be set to X,Y both minus one to match PICK assuming top left is 0,0 instead of the ANSI standard 1,1.

Both of these will be -1 if user has used the keyboard instead of the MOUSE.

PIX.MOUSE.RESPONSE Example

CALL PIX.MOUSE.RESPONSE(RESPONSE,BUTTON,XCORD,YCORD)

Make sure you have used PIX.MOUSE.ON first (see Activate a mouse).

Will, if the mouse is active, wait until the mouse button has been pressed and return in XCORD and YCORD the X,Y position of the mouse cursor when a button was pressed. BUTTON is returned as a code for whichever mouse button has been pressed. If BUTTON is -1 then RESPONSE will contain the text string that the user must have typed in and pressed return to.

Turn off mouse event reporting

PIX.MOUSE.OFF is a BASIC subroutine that can be called from your applications as follows:

CALL PIX.MOUSE.OFF

This program will stop HostAccess returning anything when the mouse is used. The mouse should be turned off when not in use to stop input being passed into non-mouse host applications.

Mouse test program

PIX.MOUSE.TEST is a BASIC subroutine that can be called from your applications as follows:

CALL PIX.MOUSE.TEST

This program simply demonstrates how the MOUSE can be used within a host application.

It only runs if the PIX.MOUSE.ACTIVE returns true, i.e. if you have loaded a mouse driver into your PC. It will not work unless you have this driver loaded.

This program demonstrates using the MOUSE continuously. With a button down you can drag a box around the screen. EVERY event is monitored and displayed on the status line.

Try changing some of the parameters and experiment with other mouse detect buttons.