Skip to content

Support custom cursors in the web backend - #203

Merged
treeform merged 1 commit into
masterfrom
fix-web-custom-cursors
Oct 28, 2026
Merged

treeform merged 1 commit into
masterfrom
fix-web-custom-cursors

Conversation

@treeform

Copy link
Copy Markdown
Owner

Assigning CustomCursor on Emscripten previously reset the browser cursor to auto. Encode the supplied image as a PNG data URL and apply its hotspot through the canvas CSS cursor property. A nil image keeps the default cursor, and image encoding failures are reported as WindyError.

Use Pixie's existing encodeImage(PngFormat) API with standard base64 encoding so the change remains compatible with the pinned Pixie 5.1.0 dependency. The string passed to JavaScript now uses an explicit cstring conversion.

Validation:

  • nim check --threads:off -d:emscripten examples/custom_cursor.nim passed.
  • nim c --threads:off -d:emscripten examples/custom_cursor.nim passed with Nim 2.2.10 and Emscripten 6.0.1.
  • Ran the compiled example in the browser: the initial 32-by-32 PNG cursor uses hotspot (0, 0), one left click switches to auto, and the second restores the custom cursor. No browser warnings or errors.
  • git diff --check passed.

@treeform
treeform merged commit bbe05ec into master Oct 28, 2026
3 checks passed
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.

1 participant