Introduction

Language Structure

IB Statements

File System

Comet 32 Runtime

Index

Mouse Pseudocode

The following outline provides the basic steps for reading the mouse and interpreting the 4 bytes that are returned by the mouse driver:

  1. Declare the variables that will store the mouse information

              LENGTH 2 & LOCAL MOUSECURSOR$
              LENGTH 1 & LOCAL MOUSECLICK;MOUSESTATE$
    

  2. Wait for a mouse click or poll the mouse

  3. Read the mouse values (4 bytes, binary encoded)

              MOUSE.INFO: FORMAT MOUSECURSOR$;MOUSECLICK;MOUSESTATE$
              .
              READ (0,MOUSE.INFO)
    

  4. Decode the mouse values

              ROW=ASC(MOUSECURSOR$)þ1
              COLUMN=ASC(SUB(MOUSECURSOR$,2,1))
              BUTTON=ASC(MOUSECLICK$)
              MOUSESTATE=ASC(MOUSESTATE$)
    

  5. Interpret the mouse values

    1. ROW and COLUMN are the screen coordinates where the mouse was clicked
    2. BUTTON represents which mouse button was clicked

      Value Button
      1 Left
      2 Right
      3 Left and right
      4 Center
      5 center and left
      6 Center and right
      7 All three

    3. MOUSESTATE represents the current state of the mouse

      Value State
      1 Left button down
      2 Right button down
      4 Center button down

Your program can utilize this information in whatever manner you choose. You can establish "hot" zones on the screen where a mouse click will cause some specific action to take place, you can test for different mouse buttons (up or down), and you can use the enhanced graphics characters to display items such as radio buttons and check boxes.