Jump to content

[1.11] Detecting if a mouse hovers over a certain area in the GUI


Recommended Posts

Posted

Hi,

 

I want to detect if a mouse hovers over a gui element and when it does, it will show some text.

How do I do this? I was looking into the Gui classes but I didn't find anything.

 

Thanks.

Creator of the Master Chef Mod and many more to come.

 

If I helped you, please click the 'thank you' button.

Posted

If you know the X coordinate, Y coordinate, width, and height of your GUI element, it's a simple matter of a couple less than/greater than checks. You need to check that:

 

  • mouse X >= element X
  • mouse Y >= element Y
  • mouse X <= element X + element Width
  • mouse Y <= element Y + element Height

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.