Skip to content

Conversation

@nyxkrage
Copy link

@nyxkrage nyxkrage commented Jan 4, 2026

Exports OptimizedBuffer.clipRectToScissor to the TypeScript interface and uses it to clip hit rects to the active scissor before adding them to the hit grid.
This fixes scrollbox content receiving clicks outside its visible bounds.

See #467 for repro example.

@kommander
Copy link
Collaborator

Cool! I'd try to do that in native only, but this works.

@nyxkrage
Copy link
Author

nyxkrage commented Jan 5, 2026

Yeah, my original idea was also to handle it all on the Zig side, but I didn't really see a good place to bridge the renderer<->buffer gap with the hitgrid being tied to the renderer context and the scissor stack being tied to the buffer, so ended doing it in TS, since it ended up being pretty straight forward.

But now taking a look again, I think I got poisoned by looking at the TS code first, because the zig renderer obviously has direct access to the buffer. Let me push up a "fix" to handle it purely in native code.

Though would there be any reason to want to add something to the hitgrid unclipped? I am not seeing any reason to not just let addToHitGrid also handle the clipping itself all the time.

@kommander
Copy link
Collaborator

Though would there be any reason to want to add something to the hitgrid unclipped?

I've been thinking about this and I can't come up with a good reason, as only things that are actually drawn would be clickable. Like you did it for the nextRenderBuffer will now only apply the scissor from the nextRenderBuffer?

I am struggling with some concepts of global vs. renderer vs. buffers, as anything should be renderer scoped to support multiple renderer instances in the same process (not fully there yet), but I also want to keep things like the buffers renderer agnostic to be able to draw a whole renderable tree with any renderer basically, if that makes sense.

Thinking about it... addToHitGrid should be a render command like pushScissor and be executed in the render pass, not the layout pass. The command can carry a reference to the buffer and use the buffer pointer to pass it to native and addToHitGrid can apply the scissor if any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants