Skip to content

Crosshair cursor for colour placement#585

Merged
tracygardner merged 1 commit intoflipcomputing:mainfrom
lawsie:colour-picker-cursor-fix
Apr 29, 2026
Merged

Crosshair cursor for colour placement#585
tracygardner merged 1 commit intoflipcomputing:mainfrom
lawsie:colour-picker-cursor-fix

Conversation

@lawsie
Copy link
Copy Markdown
Contributor

@lawsie lawsie commented Apr 29, 2026

The cursor should be a crosshair when you are filling with the colour picker. It isn't, but I think this fixes it. I haven't fully tested whether this has any knock on effects.

Summary by CodeRabbit

  • Bug Fixes
    • Improved cursor display consistency when selecting objects on the canvas. Users will now experience more reliable and consistent cursor behavior during object picking interactions.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

Refactors cursor handling in pickMeshFromCanvas by removing direct canvas element cursor assignments and instead consolidating cursor control through document body styling while delegating canvas default cursor behavior to scene-level configuration.

Changes

Cohort / File(s) Summary
Cursor Handling Refactor
ui/gizmos.js
Consolidates cursor assignment in pickMeshFromCanvas: removes direct assignments to both document.body and canvas element, instead using document.body.style.cursor and flock.scene.defaultCursor = "crosshair" for centralized cursor control.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Gizmo kb controls #539: Both PRs modify cursor and interaction behavior in ui/gizmos.js—this PR refactors cursor assignment to use scene-level defaults while the related PR reorganizes keyboard placement logic and gizmo interaction modes.

Poem

A rabbit refined the cursor's dance, 🐰
From canvas chaos to scene's expanse,
No more direct styling's fuss,
defaultCursor handles us,
Crosshairs gleam with elegance! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title focuses on 'colour placement' but the changeset addresses cursor handling during mesh picking with crosshair assignment, which is broader than just colour picker placement. Clarify whether the title should reflect the broader mesh picking cursor change or if it should be more specific to colour picker functionality as intended.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/gizmos.js (1)

210-216: ⚠️ Potential issue | 🟡 Minor

Use shared cursor helpers here (and remove the transient inline comment).

This path manually mutates cursor state instead of using setCrosshairCursor() / setDefaultCursor(), which makes cursor behavior easier to drift from other flows. Also, // works is not a durable code comment.

♻️ Proposed fix
-      // restore cursors
-      document.body.style.cursor = "default";
-      flock.scene.defaultCursor = "";
+      setDefaultCursor();
       return;
@@
-  document.body.style.cursor = "crosshair"; // works
-  flock.scene.defaultCursor = "crosshair";
+  setCrosshairCursor();

As per coding guidelines **/*.{js,ts,tsx,jsx,py,java,go,rb,php,cs,cpp,c}: "Comments should be infrequent", "Comments should be genuinely noteworthy", and "Comments should reflect the current state of code only."

Also applies to: 223-225

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/gizmos.js` around lines 210 - 216, Replace the manual cursor mutations and
transient comment in the out-of-bounds branch with the shared cursor helpers:
instead of setting document.body.style.cursor and flock.scene.defaultCursor
directly, call setDefaultCursor() (and use setCrosshairCursor() where
appropriate in nearby logic); keep the existing cleanup steps
(removeEventListener("click", onPickMesh) and stopCanvasKeyboardMode()) intact
and remove the inline "// restore cursors" / "// works" comments. Apply the same
replacement for the other similar block that directly mutates cursors (the block
that currently sets document.body.style.cursor and flock.scene.defaultCursor
around onPickMesh/stopCanvasKeyboardMode).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ui/gizmos.js`:
- Around line 210-216: Replace the manual cursor mutations and transient comment
in the out-of-bounds branch with the shared cursor helpers: instead of setting
document.body.style.cursor and flock.scene.defaultCursor directly, call
setDefaultCursor() (and use setCrosshairCursor() where appropriate in nearby
logic); keep the existing cleanup steps (removeEventListener("click",
onPickMesh) and stopCanvasKeyboardMode()) intact and remove the inline "//
restore cursors" / "// works" comments. Apply the same replacement for the other
similar block that directly mutates cursors (the block that currently sets
document.body.style.cursor and flock.scene.defaultCursor around
onPickMesh/stopCanvasKeyboardMode).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ec1483b3-8a98-42fe-9279-11c7207f9840

📥 Commits

Reviewing files that changed from the base of the PR and between b8dc98d and 7cba866.

📒 Files selected for processing (1)
  • ui/gizmos.js

@tracygardner tracygardner merged commit e4cebff into flipcomputing:main Apr 29, 2026
5 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.

2 participants