Show the hand cursor when hovering links (RichTextArea renderer)#8
Merged
Conversation
RichTextArea gives every text segment the default I-beam cursor, so links were indistinguishable from ordinary selectable text on hover — unlike FxRenderer, whose link runs already carry Cursor.HAND. The control has no built-in link support, but its rendering is driven by an overridable StyleHandlerRegistry. HtmlRichTextArea overrides getStyleHandlerRegistry() to extend the control's default registry with a segment handler for the custom HREF attribute that appends `-fx-cursor: hand` through the CellContext — the same mechanism the built-in bold/italic/color handlers use. Because the skin replaces each segment node's inline style on every layout, a recycled node reused for a non-link run does not keep a stale hand cursor. Wired into RichTextRenderer.render and RichHtmlView; covered by a gui-tagged test that drives the same StyleHandlerRegistry.process path the skin uses. Fixes #5 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 PR Description
Problem
Fixes #5.
In the
RichTextArea-based renderer (RichHtmlView/RichTextRenderer), hovering a link shows the default text (I-beam) cursor, so a link looks no different from ordinary selectable text. TheTextFlow-basedFxRendereralready setsCursor.HANDon its link runs, so the two renderers were inconsistent.RichTextArea(JavaFX incubator) has no built-in concept of a link cursor — confirmed by the control's author on openjdk/jfx#2196 (comment), who recommended reacting to a custom characterStyleAttributevia the control's style-handler registry.Fix
New
rich/HtmlRichTextAreasubclass overridinggetStyleHandlerRegistry()to return the control's default registry extended with a segment handler for the existing customHREFattribute. The handler appends-fx-cursor: handto the run's node through theCellContext— the same mechanism the built-in bold/italic/underline/color handlers use.StyleHandlerRegistry.builder(RichTextArea.styleHandlerRegistry)seeds the new registry with all of the control's default handlers, so bold/italic/color/… keep working.registry.process(...), soHREFreliably reaches the handler.Wired into the two construction sites:
RichTextRenderer.render(...)andRichHtmlView.Testing
./gradlew build(headless) — green.xvfb-run ./gradlew guiTest— green, including the newHtmlRichTextAreaTest, which drives the sameStyleHandlerRegistry.process(...)path the skin uses and asserts that a link run requests-fx-cursor:hand, that inherited handlers (bold) still apply, and that a non-link run does not get the hand cursor.To see it manually: render any HTML containing an
<a href>into aRichHtmlViewand hover the link — the pointer becomes a hand. (No cursor-on-hover screenshot is attached because screen capture omits the OS cursor.)🤖 Generated with Claude Code