Skip to content

Add LinkLabel control#120

Open
ProGraMajster wants to merge 2 commits intomodern-forms:mainfrom
ProGraMajster:feature/controls/linklabel
Open

Add LinkLabel control#120
ProGraMajster wants to merge 2 commits intomodern-forms:mainfrom
ProGraMajster:feature/controls/linklabel

Conversation

@ProGraMajster
Copy link
Copy Markdown
Contributor

Adds LinkLabel control with support for multiple links and link states (hover, active, visited). Includes input handling. Demo panel in ControlGallery

image

Supports multiple links, hover/active/visited states and demo panel
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new LinkLabel control to Modern.Forms, enabling multiple clickable link ranges with hover/active/visited states, plus a ControlGallery demo panel to showcase usage.

Changes:

  • Introduces LinkLabel (links collection, link state handling, keyboard/mouse interaction, events, and supporting types).
  • Adds LinkLabelRenderer and registers it in RenderManager.
  • Adds a new ControlGallery panel and navigation entry for LinkLabel.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/Modern.Forms/Renderers/RenderManager.cs Registers the new LinkLabelRenderer for LinkLabel.
src/Modern.Forms/Renderers/LinkLabelRenderer.cs Implements drawing, layout caching, focus cues, and hit-testing for links.
src/Modern.Forms/LinkLabel.cs New control implementation: link management, input handling, events, and layout invalidation.
src/Modern.Forms/LinkLabel.Link.cs Defines per-link data (range, state, visited, bounds for hit-testing).
src/Modern.Forms/LinkLabel.LinkCollection.cs Defines link collection behavior (add/remove/sort/validation triggers).
src/Modern.Forms/LinkState.cs Adds link visual state flags (Hover/Active/Visited).
src/Modern.Forms/LinkBehavior.cs Adds underline behavior options.
src/Modern.Forms/LinkArea.cs Adds range struct for primary link compatibility.
src/Modern.Forms/LinkLabelLinkClickedEventArgs.cs Event args for link click events.
src/Modern.Forms/LinkLabelLinkClickedEventHandler.cs Delegate type for link click event.
samples/ControlGallery/Panels/LinkLabelPanel.cs New sample panel demonstrating various LinkLabel configurations.
samples/ControlGallery/MainForm.cs Adds the new LinkLabel panel to the gallery navigation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +294 to +299

case Keys.Tab:
if (FocusNextLink (!e.Shift))
e.Handled = true;

break;
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

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

Handling Keys.Tab here (and setting e.Handled) prevents normal focus traversal out of the control. Tab is typically reserved for moving focus between controls; consider using arrow keys for intra-control link navigation so keyboard users aren’t trapped.

Suggested change
case Keys.Tab:
if (FocusNextLink (!e.Shift))
e.Handled = true;
break;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@jpobst jpobst left a comment

Choose a reason for hiding this comment

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

Just the one comment from me, and then look at the Copilot review suggestions to see which of them are good suggestions.

/// <summary>
/// Occurs when a link is clicked.
/// </summary>
public event LinkLabelLinkClickedEventHandler? LinkClicked;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove the LinkLabelLinkClickedEventHandler class and use the generic one like we do elsewhere, ex:

public event EventHandler<TreeViewDrawEventArgs>? DrawNode {
    add => Events.AddHandler (s_drawNode, value);
    remove => Events.RemoveHandler (s_drawNode, value);
}

@ProGraMajster
Copy link
Copy Markdown
Contributor Author

Pushed fixes based on review:

  • replaced custom event handler
  • fixed link ownership
  • small improvements to focus and keyboard handling

Let me know if something still needs tweaking 👍

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.

3 participants