---
description: >-
  This feature ensures that the control is fully accessible, providing keyboard
  navigation, focus handling, and descriptive text for assistive technologies.
---

# Accessibility

## Overview

The Accessibility feature of the control is implemented by overriding properties and methods such as `Text`, `OnGotFocus`, `OnLostFocus`, and `OnKeyDown`. This support makes the control operable via keyboard input (e.g., using space, enter, arrow keys) and supplies descriptive text for screen readers. The design facilitates the inclusion of the control in applications that need to meet accessibility standards, ensuring that users with disabilities can interact with the control effectively.

***

### Key Points

<table><thead><tr><th width="171">Aspect</th><th>Detail</th></tr></thead><tbody><tr><td>Properties</td><td>Text (overridden)</td></tr><tr><td>Methods</td><td>OnGotFocus, OnLostFocus, OnKeyDown</td></tr><tr><td>Data Types</td><td>Text: string; Key handling methods respond to Keys (Space, Enter, Arrow keys)</td></tr><tr><td>Default Behavior</td><td>The Text property provides a default accessible description including the current theme mode; keyboard events allow navigation and triggering mode changes</td></tr><tr><td>Effects</td><td>Improves control accessibility by providing clear focus cues, keyboard operability, and descriptive text for assistive technologies</td></tr><tr><td>Mechanism</td><td>Overrides and event handlers ensure that when the control gains or loses focus, it updates its display, and key presses trigger simulated click behavior</td></tr></tbody></table>

***

### Best Practices

<table><thead><tr><th width="309">Practice</th><th>Description</th></tr></thead><tbody><tr><td>Provide Meaningful Accessible Text</td><td>Customize the Text property to ensure it conveys relevant information for users of assistive technologies, including the control’s current mode and state.</td></tr><tr><td>Ensure Clear Focus Indicators</td><td>Implement visual cues (via focus events) so users can easily identify when the control is active, helping users navigate with the keyboard.</td></tr><tr><td>Support Keyboard Navigation</td><td>Ensure that key events (such as Space, Enter, and Arrow keys) are correctly handled to simulate clicks or toggle the theme, maintaining consistency with accessibility standards.</td></tr></tbody></table>

***

### Common Pitfalls

<table><thead><tr><th width="322">Pitfall</th><th>Description</th></tr></thead><tbody><tr><td>Overriding Without Enhancement</td><td>Simply overriding the Text property without adding descriptive details may not provide sufficient context for assistive technologies.</td></tr><tr><td>Inconsistent Focus Feedback</td><td>Failing to update the control's appearance when focus is gained or lost can confuse users who rely on keyboard navigation.</td></tr><tr><td>Neglecting Keyboard Event Handling</td><td>Ignoring key events such as Space, Enter, or Arrow keys may render the control inaccessible to users who cannot use a mouse.</td></tr></tbody></table>

***

### Usage Scenarios

<table><thead><tr><th width="317">Scenario</th><th>Description</th></tr></thead><tbody><tr><td>Screen Reader Compatibility</td><td>By providing descriptive text and managing focus events, the control is accessible for users who rely on screen readers.</td></tr><tr><td>Keyboard-Only Navigation</td><td>The control supports navigation and mode changes using the keyboard, making it suitable for applications designed for users with mobility impairments.</td></tr><tr><td>High-Contrast and Focus-Enhanced Interfaces</td><td>Developers can utilize the focus events to create high-contrast visual feedback, ensuring that the control meets accessibility standards in diverse environments.</td></tr></tbody></table>

***

### Real Life Usage Scenarios

<table><thead><tr><th width="307">Scenario</th><th>Description</th></tr></thead><tbody><tr><td>Enterprise Applications</td><td>In corporate software where accessibility is a compliance requirement, the control’s built-in focus and keyboard support ensures that all users can interact with it.</td></tr><tr><td>Public Sector Websites and Kiosks</td><td>Applications in public services often need to meet strict accessibility guidelines; integrating the control with descriptive text and keyboard navigation aids in compliance.</td></tr><tr><td>Adaptive Learning Environments</td><td>In educational software, ensuring that interactive elements are accessible via keyboard and screen readers enhances the usability for students with disabilities.</td></tr></tbody></table>

***

### Troubleshooting Tips

<table><thead><tr><th width="258">Tip</th><th>Description</th></tr></thead><tbody><tr><td>Validate Accessible Text</td><td>Ensure that the overridden Text property reflects the current state (e.g., "Theme Switcher - Current Mode: Light") and update it as needed when the state changes.</td></tr><tr><td>Test Keyboard Navigation</td><td>Manually test the control by navigating with the keyboard (using Space, Enter, Arrow keys) to ensure that all key events trigger the expected behavior.</td></tr><tr><td>Check Focus Event Behavior</td><td>Use debugging tools to verify that OnGotFocus and OnLostFocus are being called appropriately and that visual indicators for focus are noticeable.</td></tr></tbody></table>

***

### Code Examples

#### Basic Integration with Accessibility

```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;

public class AccessibleForm : Form
{
    public AccessibleForm()
    {
        // Initialize the theme switcher control with accessibility support
        var themeSwitcher = new SiticoneThemeSwitcher
        {
            Size = new Size(120, 120),
            Location = new Point(50, 50)
        };
        
        // Optionally override the accessible text
        themeSwitcher.Text = "Theme Switcher - Current Mode: Light";
        
        Controls.Add(themeSwitcher);
    }
    
    [STAThread]
    public static void Main()
    {
        Application.EnableVisualStyles();
        Application.Run(new AccessibleForm());
    }
}
```

#### Handling Keyboard Navigation

```csharp
// Assuming themeSwitcher is an existing instance of SiticoneThemeSwitcher

// This method demonstrates how keyboard input is handled internally.
// The control simulates a click when the user presses Space or Enter.
protected override void OnKeyDown(KeyEventArgs e)
{
    switch (e.KeyCode)
    {
        case Keys.Space:
        case Keys.Enter:
            // Simulate click and toggle the theme mode
            SimulateClick();
            e.Handled = true;
            break;
        case Keys.Left:
        case Keys.Up:
            // Navigate to the previous mode
            themeSwitcher.CurrentMode = (SiticoneThemeSwitcher.ThemeMode)(((int)themeSwitcher.CurrentMode - 1 + 3) % 3);
            e.Handled = true;
            break;
        case Keys.Right:
        case Keys.Down:
            // Navigate to the next mode
            themeSwitcher.CurrentMode = (SiticoneThemeSwitcher.ThemeMode)(((int)themeSwitcher.CurrentMode + 1) % 3);
            e.Handled = true;
            break;
    }
    base.OnKeyDown(e);
}
```

#### Customizing Focus Appearance

```csharp
// The control automatically triggers Invalidate() in OnGotFocus and OnLostFocus.
// Developers can further customize the appearance via additional code in these methods if needed.
protected override void OnGotFocus(EventArgs e)
{
    // Additional visual cues can be implemented here
    Invalidate(); // Redraw control to indicate focus change
    base.OnGotFocus(e);
}

protected override void OnLostFocus(EventArgs e)
{
    // Clear custom focus visual cues if necessary
    Invalidate(); // Redraw control to remove focus indication
    base.OnLostFocus(e);
}
```

***

### Review

<table><thead><tr><th width="212">Aspect</th><th>Review</th></tr></thead><tbody><tr><td>Assistive Technology</td><td>The Accessibility feature ensures that screen readers receive descriptive text, improving the overall usability for visually impaired users.</td></tr><tr><td>Keyboard Operability</td><td>With comprehensive key event handling, users can navigate and interact with the control without relying on a mouse, meeting key accessibility standards.</td></tr><tr><td>Focus Feedback</td><td>Proper implementation of focus events (OnGotFocus, OnLostFocus) helps users identify which control is active, enhancing the experience for keyboard-only navigation.</td></tr></tbody></table>

***

### Summary

<table><thead><tr><th width="254">Summary Point</th><th>Description</th></tr></thead><tbody><tr><td>Enhanced Usability</td><td>The Accessibility feature enables the control to be fully operable via keyboard and accessible to assistive technologies by providing clear descriptive text and focus management.</td></tr><tr><td>Compliance with Standards</td><td>By handling key events and focus cues appropriately, the control supports accessibility requirements for a wide range of applications.</td></tr><tr><td>Integrated Event Handling</td><td>Overridden accessibility methods ensure that any state changes (focus, key events) are immediately reflected, offering a responsive user experience.</td></tr></tbody></table>

***

### Additional Sections

#### Performance Considerations

<table><thead><tr><th width="191">Consideration</th><th>Description</th></tr></thead><tbody><tr><td>Minimal Overhead</td><td>Accessibility features typically add minimal performance overhead; however, ensure that additional custom focus indicators or event handlers are optimized.</td></tr><tr><td>Efficient Redraws</td><td>As focus events trigger redraws, verify that these operations are optimized to avoid any flickering or delays, particularly in applications with multiple controls.</td></tr></tbody></table>

#### Customization Tips

<table><thead><tr><th width="254">Tip</th><th>Description</th></tr></thead><tbody><tr><td>Customize Accessible Text</td><td>Tailor the Text property to provide more context when needed (e.g., including instructions or state details) for users relying on assistive technologies.</td></tr><tr><td>Enhance Focus Indicators</td><td>Consider adding custom visual cues (e.g., a colored border or shadow) when the control gains focus to further assist users in identifying active elements.</td></tr><tr><td>Test with Accessibility Tools</td><td>Use screen readers and keyboard navigation testing tools to validate that the control meets accessibility standards and performs as expected in various scenarios.</td></tr></tbody></table>

***

This extensive documentation for the Accessibility feature provides developers with a detailed guide on integrating and optimizing accessible behavior for the theme switcher control. The provided tables, code examples, and troubleshooting tips are designed to help ensure that the control is fully accessible and user-friendly in .NET WinForms applications.
