Conversation
Supports multiple links, hover/active/visited states and demo panel
There was a problem hiding this comment.
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
LinkLabelRendererand registers it inRenderManager. - 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.
src/Modern.Forms/LinkLabel.cs
Outdated
|
|
||
| case Keys.Tab: | ||
| if (FocusNextLink (!e.Shift)) | ||
| e.Handled = true; | ||
|
|
||
| break; |
There was a problem hiding this comment.
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.
| case Keys.Tab: | |
| if (FocusNextLink (!e.Shift)) | |
| e.Handled = true; | |
| break; |
jpobst
left a comment
There was a problem hiding this comment.
Just the one comment from me, and then look at the Copilot review suggestions to see which of them are good suggestions.
src/Modern.Forms/LinkLabel.cs
Outdated
| /// <summary> | ||
| /// Occurs when a link is clicked. | ||
| /// </summary> | ||
| public event LinkLabelLinkClickedEventHandler? LinkClicked; |
There was a problem hiding this comment.
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);
}
|
Pushed fixes based on review:
Let me know if something still needs tweaking 👍 |
Adds LinkLabel control with support for multiple links and link states (hover, active, visited). Includes input handling. Demo panel in ControlGallery