<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/IsCursorOnElement?action=history&amp;feed=atom</id>
	<title>IsCursorOnElement - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/IsCursorOnElement?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsCursorOnElement&amp;action=history"/>
	<updated>2026-04-05T23:47:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=IsCursorOnElement&amp;diff=82798&amp;oldid=prev</id>
		<title>Knower: Created page with &quot;== Client-Side Function: isCursorOnElement ==  thumb '''Description:''' This function is used in GUI / DX to create interactive buttons or effects in a professional way.  It allows you to make elements like buttons, rectangles, or any selectable area responsive to the player's cursor.  You can also add many enhancements to make the appearance of the button or element look visually appealing and professional. ---  === Function === &lt;syntaxhighlight la...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=IsCursorOnElement&amp;diff=82798&amp;oldid=prev"/>
		<updated>2026-04-05T15:19:18Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Client-Side Function: isCursorOnElement ==  &lt;a href=&quot;/wiki/File:MTANeonX.png&quot; title=&quot;File:MTANeonX.png&quot;&gt;thumb&lt;/a&gt; &amp;#039;&amp;#039;&amp;#039;Description:&amp;#039;&amp;#039;&amp;#039; This function is used in GUI / DX to create interactive buttons or effects in a professional way.  It allows you to make elements like buttons, rectangles, or any selectable area responsive to the player&amp;#039;s cursor.  You can also add many enhancements to make the appearance of the button or element look visually appealing and professional. ---  === Function === &amp;lt;syntaxhighlight la...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Client-Side Function: isCursorOnElement ==&lt;br /&gt;
&lt;br /&gt;
[[File:MTANeonX.png|thumb]]&lt;br /&gt;
'''Description:'''&lt;br /&gt;
This function is used in GUI / DX to create interactive buttons or effects in a professional way. &lt;br /&gt;
It allows you to make elements like buttons, rectangles, or any selectable area responsive to the player's cursor. &lt;br /&gt;
You can also add many enhancements to make the appearance of the button or element look visually appealing and professional.&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
=== Function ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
function isCursorOnElement( posX, posY, width, height )&lt;br /&gt;
&lt;br /&gt;
	if isCursorShowing( ) then&lt;br /&gt;
&lt;br /&gt;
		local mouseX, mouseY = getCursorPosition( )&lt;br /&gt;
&lt;br /&gt;
		local clientW, clientH = guiGetScreenSize( )&lt;br /&gt;
&lt;br /&gt;
		local mouseX, mouseY = mouseX * clientW, mouseY * clientH&lt;br /&gt;
&lt;br /&gt;
		if ( mouseX &amp;gt; posX and mouseX &amp;lt; ( posX + width ) and mouseY &amp;gt; posY and mouseY &amp;lt; ( posY + height ) ) then&lt;br /&gt;
&lt;br /&gt;
			return true&lt;br /&gt;
&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	return false&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
=== Example Usage ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Example: Interactive button on screen&lt;br /&gt;
&lt;br /&gt;
local SelectBut = 1 -- Stores the button selected by player&lt;br /&gt;
local x, y, w, h = 100, 100, 150, 50 -- Element position and size&lt;br /&gt;
&lt;br /&gt;
if isCursorOnElement(x, y, w, h) then&lt;br /&gt;
    -- Cursor is on the element → full alpha&lt;br /&gt;
    dxDrawImage(x, y, w, h, &amp;quot;img.png&amp;quot;, 0, 0, 0, tocolor(255, 254, 254, 255), false)&lt;br /&gt;
else&lt;br /&gt;
    if SelectBut == 1 then&lt;br /&gt;
        -- Cursor is not on the element but already selected → full alpha&lt;br /&gt;
        dxDrawImage(x, y, w, h, &amp;quot;img.png&amp;quot;, 0, 0, 0, tocolor(255, 254, 254, 255), false)&lt;br /&gt;
    else&lt;br /&gt;
        -- Cursor is not on the element and not selected → reduce alpha&lt;br /&gt;
        dxDrawImage(x, y, w, h, &amp;quot;img.png&amp;quot;, 0, 0, 0, tocolor(255, 254, 254, 50), false)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
===Explanation ===&lt;br /&gt;
* '''isCursorOnElement(posX, posY, width, height)''' Function to check cursor position relative to an element  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
&lt;br /&gt;
=== Notes===&lt;br /&gt;
* This function is safe for Client-Side only and will not affect other players.&lt;br /&gt;
* GUI/DX Example can be adapted for multiple buttons or GUI elements easily.&lt;/div&gt;</summary>
		<author><name>Knower</name></author>
	</entry>
</feed>