Add MarkdownRenderer.getLinkAtPosition() for clickable links on ScriptPanels - #1007
Open
weavermedia wants to merge 1 commit into
Open
Add MarkdownRenderer.getLinkAtPosition() for clickable links on ScriptPanels#1007weavermedia wants to merge 1 commit into
weavermedia wants to merge 1 commit into
Conversation
…tPanels Markdown text drawn on a ScriptPanel via Content.createMarkdownRenderer() and Graphics.drawMarkdownText() renders hyperlinks as underlined text, but there was no way for the script to detect clicks on them. This adds a getLinkAtPosition([x, y]) method to the scripting MarkdownRenderer object that returns the URL of the hyperlink at the given panel-relative position (or an empty string), so a panel mouse callback can open links with Engine.openWebsite() and show a hand cursor on hover. The hit-test reuses the existing hyperlink rectangles: the body of MarkdownParser::getHyperLinkForEvent is extracted unchanged into a new point-based getHyperLinkForPoint, with the event version delegating to it, so all existing callers behave identically. Requested on the forum: https://forum.hise.audio/topic/14023/how-to-do-text-links-in-a-settings-panel Co-Authored-By: Claude Fable 5 <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.
Markdown text drawn on a ScriptPanel via
Content.createMarkdownRenderer()andGraphics.drawMarkdownText()renders hyperlinks as underlined text, but there is no way for the script to detect clicks on them, so links are purely decorative.This adds one scripting API method to the MarkdownRenderer object:
It returns the URL of the hyperlink at the given panel-relative
[x, y]position, or an empty string. The script decides what to do with the link, and the same call drives a hand cursor on hover.Implementation notes:
MarkdownParser::getHyperLinkForEventis extracted unchanged into a new point-basedgetHyperLinkForPoint, with the event version delegating to it, so all existing callers (doc browser etc.) behave identically.setTextBounds()and takes the same lock as the other MarkdownRenderer scripting methods.setTextBounds()has not been called yet; a malformed position argument reports a script error via the existingApiHelpers::getPointFromVarvalidation.Tested in the IDE: clicking a rendered link opens the browser, clicks on plain text and empty space do nothing, hover cursor works, and internal and external links in the in-app documentation browser still work through the delegating code path.
Requested on the forum: https://forum.hise.audio/topic/14023/how-to-do-text-links-in-a-settings-panel
🤖 Generated with Claude Code