You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This explains how to handle the ValueChange event and bind standard Blazor native DOM events to the Toggle Switch Button component for common interaction scenarios such as focus, keyboard, mouse, and touch.
13
+
12
14
## ValueChange Event
13
15
14
-
The ValueChange event will trigger when switch state has been changed by user interaction. ValueChange event argument type is [ChangeEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html). [ChangeEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html)contains [Checked](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html#Syncfusion_Blazor_Buttons_ChangeEventArgs_1_Checked) and [Event](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html#Syncfusion_Blazor_Buttons_ChangeEventArgs_1_Event) properties.
16
+
The ValueChange event is triggered when the switch state changes through user interaction. The ValueChange event argument type is [ChangeEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html). [ChangeEventArgs](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html)includes the [Checked](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html#Syncfusion_Blazor_Buttons_ChangeEventArgs_1_Checked) and [Event](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Buttons.ChangeEventArgs-1.html#Syncfusion_Blazor_Buttons_ChangeEventArgs_1_Event) properties for obtaining the current state and the associated event details.
15
17
16
18
```csharp
17
19
@@ -29,50 +31,212 @@ The ValueChange event will trigger when switch state has been changed by user in
InadditiontotheValueChangecomponentevent, theToggleSwitchButtonsupportsstandardBlazornativeDOMeventsfor detailed control over user interactions. Attach native event handlers using Blazor's `@on*` directives (forexample, `@onfocus`, `@onkeydown`), andaccessevent-specificdatathroughthecorrespondingeventargumenttype.
FocuseventsfirewhentheToggleSwitchButtonreceivesorlosesfocus. The`FocusEventArgs` parameterprovidesaccesstofocusstateinformationfor implementing accessibility features and focus-dependent logic.
37
52
38
-
Thedifferenteventargumenttypesforeacheventare,
53
+
| Event | Behavior |
54
+
|---|---|
55
+
| **onfocus** | Fires when the component gains focus |
56
+
| **onfocusin** | Fires when the component gains focus, including during event bubbling |
57
+
| **onfocusout** | Fires when the component loses focus |
58
+
59
+
The following example demonstrates handling focus events on the Toggle Switch Button:
Keyboard events are triggered when keyboard interactions occur on the Toggle Switch Button component. The `KeyboardEventArgs` event argument provides information about which key was pressed and keyboard modifiers, allowing you to handle keyboard navigation and shortcuts.
55
94
56
-
## How to bind focus event to Toggle Switch Button
95
+
| Event | Behavior |
96
+
|---|---|
97
+
|**onkeydown**| Fires when a key is pressed |
98
+
|**onkeyup**| Fires when a pressed key is released |
99
+
|**onkeypress**| Fires when a key is pressed (generally use onkeydown for better compatibility) |
Mouse events fire when the user interacts with the Toggle Switch Button using the mouse. The `MouseEventArgs` parameter provides positional data, button information, and other mouse-related properties.
136
+
137
+
**Event Types:**| Event | Behavior |
138
+
|---|---|
139
+
|**onclick**| Fires when the component is clicked |
140
+
|**ondbclick**| Fires when the component is double-clicked |
141
+
|**onmousedown**| Fires when a mouse button is pressed down |
142
+
|**onmouseup**| Fires when a mouse button is released |
143
+
|**onmousemove**| Fires as the mouse pointer moves over the component |
144
+
|**onmouseenter**| Fires when the mouse pointer enters the component area |
145
+
|**onmouseleave**| Fires when the mouse pointer leaves the component area |
146
+
147
+
The following example demonstrates handling mouse events:
Touch events fire when the user interacts with the Toggle Switch Button using touch input on touch-enabled devices (tablets, smart phones, etc.). The `TouchEventArgs` parameter provides information about touch points and their positions.
202
+
203
+
| Event | Behavior |
204
+
|---|---|
205
+
|**ontouchstart**| Fires when one or more touch points contact the component |
206
+
|**ontouchend**| Fires when one or more touch points are removed from the component |
207
+
|**ontouchmove**| Fires when one or more touch points move while in contact with the component |
208
+
209
+
The following example demonstrates handling touch events:
0 commit comments