You can initiate an action based on the mouse's current location, whether the mouse is in an item, record, coordinate area, or canvas.
/* ** 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);