Skip to main content

The "device_mouse_check_region_gui" Function

Syntax#

device_mouse_check_region_gui(device, x, y, rot, width, [height], [halign, valign]);
ArgumentTypeDescription
deviceintegerThe mouse or touch point to check, where 0 is first
xrealThe horizontal GUI coordinate for the region to check
yrealThe horizontal GUI coordinate for the region to check
rotrealThe rotation of the region to check, if rectangular
widthrealThe width (or radius) in pixels of the region to check
[height]realOptional: The height in pixels of the region to check (use none for circular)
[halign]constantOptional: The horizontal alignment of the region to check (use none for fa_center)
[valign]constantOptional: The vertical alignment of the region to check (use none for fa_middle)

Description#

Checks whether the mouse is currently within a certain region relative to GUI coordinates and returns true or false. If only a region width is specified, it will be interpreted as a radius and the region to check will be circular. For other shapes, a rotated rectangle can be used to cover most areas.

By default, the region to check will be aligned to the center, but this can be changed by specifying optional halign and valign values using font alignment constants such as fa_left and fa_top. Alignment must be input as a pair.

Example#

//Rectangular region
if (device_mouse_check_region_gui(0, 640, 480, 0, 512, 384)) {
//Action
}
//Diamond region
if (device_mouse_check_region_gui(0, 640, 480, 45, 256, 256)) {
//Action
}
//Circular region with custom alignment
if (device_mouse_check_region_gui(0, 256, 128, 0, 512, fa_left, fa_top)) {
//Action
}