version 2004
DR GET MOUSE (area; horizontal; vertical)
| Parameter | Type | Description | |
| area | Longint | 4D Draw area | |
| horizontal | Number | Horizontal position of mouse cursor | |
| vertical | Number | Vertical position of mouse cursor |
Description
The DR GET MOUSE command returns the current location of the mouse cursor in the horizontal and vertical variables. This position is calculated with respect to the origin of area and is expressed in base units (inches, points, centimeters). The DR Base to scale command can be used to convert the base units to scale units.
The command returns the location of the mouse cursor, regardless of whether or not the mouse button is pressed. During a dragging or resizing operation, DR GET MOUSE returns the position of the mouse when its button is released.
If the command has been correctly executed, the system variable OK is set to 1; otherwise, it is set to 0.
Example
This example describes the installation of a process method displaying the coordinates of the mouse in a separate window when it moves over the 4D Draw area.
The zDrInfoGetMouse method launches the process which returns the mouse position:
`zDrInfoGetMouse method
C_LONGINT($NewProc)
$NewProc:=New process("zDrGetMouse";256;"MyTest";Drawarea)
The zDrGetMouse method, called using the $NewProc process, displays the X and Y coordinates of the mouse in a window until the user presses the Shift key:
`zDrGetMouse method
C_REAL($MouseX;$MouseY)
$ref:=Open window(50;80;300;125;-Palette window;"Mouse position";"CloseBox")
GOTO XY(1;0)
MESSAGE("Press Shift to exit process")
GOTO XY(1;1)
MESSAGE("Values in X / Y")
Repeat
DR GET MOUSE ($1;$MouseX;$MouseY)
GOTO XY(1;2)
MESSAGE(String($MouseX)+" / "+String($MouseY)+" ")
Until (Shift down)
CLOSE WINDOW