Class FocusStateHelper
- Namespace
- SharpConsoleUI.Helpers
- Assembly
- SharpConsoleUI.dll
Helper class for managing focus state updates across controls. Eliminates 100% identical SetFocus boilerplate from 8+ simple controls.
public static class FocusStateHelper
- Inheritance
-
FocusStateHelper
- Inherited Members
Methods
HandleSetFocus(IWindowControl, ref bool, bool, FocusReason, EventHandler?, EventHandler?, bool)
Handles focus state changes for controls with standard focus behavior. Use this for simple controls (Button, Checkbox, etc.) that don't need custom focus logic. DO NOT use for complex controls (TreeControl, ListControl) that have custom focus handling.
public static void HandleSetFocus(IWindowControl control, ref bool hasFocusField, bool focus, FocusReason reason, EventHandler? gotFocusEvent, EventHandler? lostFocusEvent, bool invalidate = true)
Parameters
controlIWindowControlThe control receiving the focus change
hasFocusFieldboolReference to the control's _hasFocus field
focusboolTrue to give focus, false to remove focus
reasonFocusReasonReason for the focus change
gotFocusEventEventHandlerThe control's GotFocus event to invoke
lostFocusEventEventHandlerThe control's LostFocus event to invoke
invalidateboolWhether to invalidate the container after focus change