> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/gum-runtime-api/gum-wireframe-graphicaluielement/hascursorover.md).

# HasCursorover

### Introduction

HasCursorOver is used to return if the argument world X and world Y coordinates are inside the calling GraphicalUiElements. This is an extension method requiring the RenderingLibrary namespace. Despite its name, this can be used to detect if a pair of world coordinates are inside the caller regardless of whether this is for UI/cursor checks or otherwise.

### Code Example - Detecting GuiManager.Cursor Over Gum Object

The following code can be used to determine if the cursor is over a GraphicalUiElement. Note, this does a bounds check on the Gum object even if the Gum object is not raising events.

```
void CustomActivity(bool firstTimeCalled)
{
    var cursor = GuiManager.Cursor;

    var isCursorOver = GumScreen.ColoredRectangleInstance.HasCursorOver(cursor);

    FlatRedBall.Debugging.Debugger.Write($"Cursor over: {isCursorOver}");
}
```

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-aa67709b1793f7356cdb439861e58551290ef32e%2F2019-09-20_05-26-27.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Code Example - Detecting Screen Coordinates on GraphicalUiElement

The following code shows how to detect if a ScreenX and ScreenY pair are inside a particular GraphicalUiElement:

```lang:c#
// Since this is an extension method, the following is required:
using RenderingLibrary;

// assuming screenX and screenY are valid screen coordinates

float worldX;
float worldY;

// Assuming the game uses the default system managers
var managers = global::RenderingLibrary.SystemManagers.Default;

screenX -= managers.Renderer.GraphicsDevice.Viewport.X;
screenY -= managers.Renderer.GraphicsDevice.Viewport.Y;

managers.Renderer.Camera.ScreenToWorld(
    screenX, screenY,
    out worldX, out worldY);

var isOver = graphicalUiElement.HasCursorOver(worldX, worldY);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/api/gum-runtime-api/gum-wireframe-graphicaluielement/hascursorover.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
