Compare commits

...

2 Commits

Author SHA1 Message Date
Nick
62b402bcbb
Merge 46c962d7f2 into 08e4c5b198 2025-03-26 04:39:22 +08:00
Nicholas Molloy
46c962d7f2 Update the pointer state before the onHover function is called 2025-03-03 14:18:36 +13:00

29
clay.h
View File

@ -3794,6 +3794,21 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
}
context->pointerInfo.position = position;
context->pointerOverIds.length = 0;
if (isPointerDown) {
if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED;
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_PRESSED) {
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME;
}
} else {
if (context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) {
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED;
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_RELEASED) {
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
}
}
Clay__int32_tArray dfsBuffer = context->layoutElementChildrenBuffer;
for (int32_t rootIndex = context->layoutElementTreeRoots.length - 1; rootIndex >= 0; --rootIndex) {
dfsBuffer.length = 0;
@ -3845,20 +3860,6 @@ void Clay_SetPointerState(Clay_Vector2 position, bool isPointerDown) {
break;
}
}
if (isPointerDown) {
if (context->pointerInfo.state == CLAY_POINTER_DATA_PRESSED_THIS_FRAME) {
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED;
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_PRESSED) {
context->pointerInfo.state = CLAY_POINTER_DATA_PRESSED_THIS_FRAME;
}
} else {
if (context->pointerInfo.state == CLAY_POINTER_DATA_RELEASED_THIS_FRAME) {
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED;
} else if (context->pointerInfo.state != CLAY_POINTER_DATA_RELEASED) {
context->pointerInfo.state = CLAY_POINTER_DATA_RELEASED_THIS_FRAME;
}
}
}
CLAY_WASM_EXPORT("Clay_Initialize")