Enhance focus rectangle support and rendering for buttons#3256
Conversation
mrngButton and CommandButton now visually indicate focus by drawing a focus rectangle when focused and enabled. Added OnGotFocus/OnLostFocus handlers to manage focus state. Also, set the default focus control in frmTaskDialog for each button configuration. Updated build number to 3468.
The focus rectangle is now drawn slightly inset from the button's border, rather than covering the entire ClientRectangle. This adjustment enhances the visual appearance by preventing overlap with the button's border.
Review Summary by QodoAdd visual focus indication to custom button controls
WalkthroughsDescription• Add focus rectangle rendering to mrngButton and CommandButton controls • Implement OnGotFocus/OnLostFocus handlers for focus state management • Ensure default button receives focus in all dialog configurations • Update build number from 3465 to 3468 Diagramflowchart LR
A["Button Controls<br/>mrngButton & CommandButton"] -->|"Add focus state tracking"| B["_hasFocus property"]
B -->|"OnGotFocus/OnLostFocus"| C["Focus state management"]
C -->|"OnPaint override"| D["Draw focus rectangle"]
E["frmTaskDialog"] -->|"Set default focus"| F["Button configurations"]
F -->|"All button types"| G["Improved focus assignment"]
H["AssemblyInfo.cs"] -->|"Update version"| I["Build 3468"]
File Changes1. mRemoteNG/Properties/AssemblyInfo.cs
|
Code Review by Qodo
1.
|
Reset and reassign _focusControl on dialog rebuilds to avoid stale references. Add safety checks before focusing to prevent exceptions and ensure the correct button receives focus.
Removed private _hasFocus fields and related focus event overrides from mrngButton and CommandButton. Now use the built-in Focused property to determine focus state when drawing focus rectangles, simplifying the code and relying on standard control behavior.
|
Removed the duplicate _hasFocus field tracking from both button classes and replaced it with the built-in Focused property provided by the WinForms Button base class |
Review Summary by QodoAdd visual focus indication to custom button controls
WalkthroughsDescription• Add focus rectangle rendering to custom button controls • Improve focus assignment in TaskDialog for all button configurations • Add safety checks before focusing to prevent exceptions • Update build number to 3468 Diagramflowchart LR
A["mrngButton & CommandButton"] -->|"Draw focus rectangle"| B["OnPaint override"]
C["frmTaskDialog"] -->|"Reset _focusControl"| D["BuildForm method"]
D -->|"Assign default button"| E["Each button configuration"]
E -->|"Focus with safety checks"| F["frmTaskDialog_Shown"]
File Changes1. mRemoteNG/Properties/AssemblyInfo.cs
|
Code Review by Qodo
|
|



This pull request introduces improvements to the focus handling and visual feedback for custom button controls in the UI, ensuring that buttons display a focus rectangle when selected and that focus assignment is more robust in dialog forms. Additionally, it updates the build number and version information for the application.
UI/UX Improvements:
Added logic to both
mrngButtonandCommandButtoncontrols to visually indicate when the button has focus by drawing a focus rectangle, and implemented proper focus state management through overrides ofOnGotFocusandOnLostFocus. [1] [2] [3] [4] [5] [6]Improved focus assignment in
frmTaskDialog.csby ensuring that the default button receives focus if no other control is set, across all dialog button configurations. [1] [2] [3] [4]Versioning:
AssemblyInfo.csto reflect the latest nightly build. [1] [2]