A script-enabled browser is required for this page to function properly.

Performing Actions Based on Mouse Location

You can initiate an action based on the mouse's current location, whether the mouse is in an item, record, coordinate area, or canvas.

Mouse in Item
 
To determine which item the mouse is in, use a When-Mouse-Move trigger in conjunction with the SYSTEM.MOUSE_ITEM system variable.
 
Mouse Coordinates
 
To initiate an action based on the current X and Y mouse coordinates, use a When-Mouse-Move trigger in conjunction with the SYSTEM.MOUSE_X_POS and SYSTEM.MOUSE_Y_POS system variables.
 
Mouse in Record
 
To perform an action based on the record number the mouse is in, use When-Mouse-Move or a When-Mouse-Click trigger in conjunction with the SYSTEM.MOUSE_RECORD system variable.

Performing actions based on mouse location Examples

/* ** Trigger: When-Mouse-Move */

DECLARE 
mouse_location varchar(50); 
BEGIN 
mouse_location := :System.Mouse_Item; 
END;
 

In the following example, the SYSTEM.MOUSE_X_POS and SYSTEM.MOUSE_Y_POS system variables are used within a When-Mouse-Click trigger to dynamically reposition items.

DECLARE
item_to_move VARCHAR(50); 
the_button_pressed VARCHAR(50); 
target_x_position VARCHAR(3); 
target_y_position VARCHAR(3); 

BEGIN 

/* ** Get the name of the item that was clicked. */ 
item_to_move := :System.Mouse_Item; 
the_button_pressed := :System.Mouse_Button_Pressed; 

/* ** If the mouse was clicked on an area of a canvas that is  
** not directly on top of another item, move the item to 
** the new mouse location. */ 

IF item_to_move IS NOT NULL AND the_button_pressed = '2' THEN 
target_x_position := :System.Mouse_X_Pos); 
target_y_position := :System.Mouse_Y_Pos); 
Set_Item_Property(item_to_move,position,target_x_position,target_y_position); 
target_x_position := NULL; 
target_y_position := NULL; 
item_to_move := NULL; 
END IF; 
END;
 

In the following example, the SYSTEM.MOUSE_CANVAS system variable is used within a When-Mouse_Move trigger to determine which canvas the mouse is in.

DECLARE
canvas_name VARCHAR(50); 
BEGIN 
canvas_name := :System.Mouse_Canvas; 
END;
 

To determine which window the mouse is in, add the following line to the example above:

window_name := :Get_View_Property(canvas_name,window_name);


About mouse events, triggers, and system variables

When-Mouse-Move Trigger

SYSTEM.MOUSE_X_POS examples

SYSTEM.MOUSE_Y_POS examples

SYSTEM.MOUSE_ITEM examples