Compare commits

..

4 Commits

Author SHA1 Message Date
Harrison Lambeth
eaa0740b21
Merge ed4b43f739 into c73dffbb6f 2025-02-13 23:56:47 -07:00
Harrison Lambeth
ed4b43f739 Add some docs 2025-02-13 23:56:37 -07:00
Harrison Lambeth
1ef4d59601 Fix some things that broke after rebasing 2025-02-13 23:45:36 -07:00
Harrison Lambeth
75338f7357 Clay_GetElementIdsAtPoint 2025-02-13 23:45:20 -07:00
2 changed files with 36 additions and 2 deletions

View File

@ -177,6 +177,7 @@ For help starting out or to discuss clay, considering joining [the discord serve
- [Clay_PointerOver](#clay_pointerover)
- [Clay_GetScrollContainerData](#clay_getscrollcontainerdata)
- [Clay_GetElementId](#clay_getelementid)
- [Clay_GetElementIdsAtPoint](#clay_getelementidsatpoint)
- [Element Macros](#element-macros)
- [CLAY](#clay-1)
- [CLAY_ID](#clay_id)
@ -197,6 +198,7 @@ For help starting out or to discuss clay, considering joining [the discord serve
- [Clay_ScrollContainerData](#clay_scrollcontainerdata)
- [Clay_ErrorHandler](#clay_errorhandler)
- [Clay_ErrorData](#clay_errordata)
- [Clay_PointQueryResult](#clay_pointqueryresult)
## High Level Documentation
@ -728,6 +730,14 @@ Returns [Clay_ScrollContainerData](#clay_scrollcontainerdata) for the scroll con
Returns a [Clay_ElementId](#clay_elementid) for the provided id string, used for querying element info such as mouseover state, scroll container data, etc.
### Clay_GetElementIdsAtPoint
`Clay_PointQueryResult Clay_GetElementIdsAtPoint(Clay_Vector2 position)`
Returns a [Clay_PointQueryResult](#clay_pointqueryresult) that contains a sorted stack of element ids at the specified position. This allows querying elements similar to [Clay_SetPointerState](#clay_setpointerstate), but without triggering hover functions or affecting hover states.
> ⚠️ The returned Clay_PointQueryResult object becomes invalid the next time you call `Clay_GetElementIdsAtPoint`. If you need to call this multiple times in a frame, you will need to copy the data out of the Clay_PointQueryResult struct.
## Element Macros
### CLAY()
@ -2129,3 +2139,27 @@ A [Clay_String](#clay_string) that provides a human readable description of the
A generic pointer to extra userdata that is transparently passed through from `Clay_Initialize` to Clay's error handler callback. Defaults to NULL.
---
### Clay_PointQueryResult
```C
typedef struct
{
int32t length;
const Clay_ElementId *results;
} Clay_PointQueryResult;
```
**Fields**
**`.length`** - `int32_t`
The number of element ids contained in `.results`.
---
**`.results`** - `Clay_ElementId*`
A pointer to a sorted array of `.length` [Clay_ElementIds](#clay_elementid), starting with the root element.
---

4
clay.h
View File

@ -3752,8 +3752,8 @@ Clay_PointQueryResult Clay_GetElementIdsAtPoint(Clay_Vector2 position) {
}
Clay_LayoutElement *rootElement = Clay_LayoutElementArray_Get(&context->layoutElements, root->layoutElementIndex);
if (found && Clay__ElementHasConfig(rootElement, CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER) &&
Clay__FindElementConfigWithType(rootElement, CLAY__ELEMENT_CONFIG_TYPE_FLOATING_CONTAINER).floatingElementConfig->pointerCaptureMode == CLAY_POINTER_CAPTURE_MODE_CAPTURE) {
if (found && Clay__ElementHasConfig(rootElement, CLAY__ELEMENT_CONFIG_TYPE_FLOATING) &&
Clay__FindElementConfigWithType(rootElement, CLAY__ELEMENT_CONFIG_TYPE_FLOATING).floatingElementConfig->pointerCaptureMode == CLAY_POINTER_CAPTURE_MODE_CAPTURE) {
break;
}
}