Program: Superbase Version: 2.0 Topic: Mouse event in Superbase Date: January 8, 1993 Summary: An event procedure is a SUB procedure that is triggered by an event, such as a mouse click or a keystroke, and responds by executing the code for the event. Superbase supports seven event classes. This technote concentrates on a mouse event and its use during data entry in a multi-file form. This technote uses the example files from the STOCK directory to illustrate the example. Consider the following DML program. ( The lines starting with REM: are remarks for user readability and can be ignored) REM: Switch to the stock directory. DIRECTORY "c:\sb4w\samples\stock" REM: Open the following files. OPEN FILE "Customer" OPEN FILE "Items" OPEN FILE "Order" OPEN FILE "Video" REM: Load the multi-file form ORDER. LOAD FORM "Order" REM: Make the Customer file the current file and CustomerNo field the current index. FILE "Customer" INDEX customerno.Customer REM: Select the record for which customerno.Customer=00178 and view it. SELECT FORM KEY "00178" FORM REM: Place the cursor on the first field and the form is ready for data entry. ENTER 1,0 END When you run the above program, the order form comes up on the screen with the 00178 record details. The cursor is blinking on the first field. Note that the detail block has its own vertical scroll bars attached. If you try to use the scroll bars on the detail block, the mouse does not respond. To activate the mouse, you need to use the mouse event class which traps mouse clicks. Note that the middle mouse button is not supported. To set up and use the mouse event is a two step procedure: * Defining an event class * Switching it on and off It is best you define all your events on the SUB main or at the very beginning of your application. You can define the mouse event by issuing the following command: ON EVENTCLASS MOUSE CALL mouseproc() When this command is executed, it checks for the syntax of mouseproc procedure, but does not actually call the procedure. The mouseproc procedure is called only when a mouse is clicked. The mouseproc procedure takes four parameters: Queue time, Button identifier and action, X coordinate, and Y coordinate. For more information, refer to Chapter 7 on Event Driven Programming in the "Developing Applications" manual. To turn on the mouse event issue the following command: EVENTCLASS MOUSE ON With these commands the above program can be rewritten as follows: SUB main() REM: Switch to the stock directory. DIRECTORY "c:\sb4w\samples\stock" REM: Define the mouse event class. ON EVENTCLASS MOUSE CALL mouseproc() REM: Open the following files. OPEN FILE "Customer" OPEN FILE "Items" OPEN FILE "Order" OPEN FILE "Video" REM: Load the multi-file form ORDER. LOAD FORM "Order" REM: Make the Customer file the current file and CustomerNo field the current index. FILE "Customer" INDEX customerno.Customer REM: Select the record for which customerno.Customer=00178 and view it. SELECT FORM KEY "00178" FORM REM: Turn on the mouse event. EVENTCLASS MOUSE ON REM: Place the cursor on the first field and the form is ready for data entry. ENTER 1,0 END SUB REM: mouseproc. SUB mouseproc(t%,c%%,x%%,y%%) REM: Return to Superbase for default processing as if mouse had never been trapped. EVENTDEFAULT END SUB When you run the above program notice that the user has complete control over the position of the cursor as well as the scroll bars on the detail block.