diff --git a/src/MatBlazor.Demo/Demo/DemoMatButton.razor b/src/MatBlazor.Demo/Demo/DemoMatButton.razor index fe42e508..e7e87527 100644 --- a/src/MatBlazor.Demo/Demo/DemoMatButton.razor +++ b/src/MatBlazor.Demo/Demo/DemoMatButton.razor @@ -9,7 +9,7 @@ @using Microsoft.AspNetCore.Components

Simple use

- +
With Font-Awsome Icons and Link
@@ -24,6 +24,11 @@ JsRuntime.InvokeAsync("window.alert", "Test"); } + public void RunOnFocus(FocusEventArgs e) + { + Console.WriteLine(e.Type); + } + } @@ -32,7 +37,7 @@ @using Microsoft.AspNetCore.Components

Simple use

- +
With Font-Awsome Icons and Link
@@ -47,6 +52,11 @@ JsRuntime.InvokeAsync(""window.alert"", ""Test""); } + public void RunOnFocus(FocusEventArgs e) + { + Console.WriteLine(e.Type); + } + } ")> diff --git a/src/MatBlazor.Demo/Doc/DocMatButton.razor b/src/MatBlazor.Demo/Doc/DocMatButton.razor index a5d7aa04..8fbe5b8d 100644 --- a/src/MatBlazor.Demo/Doc/DocMatButton.razor +++ b/src/MatBlazor.Demo/Doc/DocMatButton.razor @@ -79,6 +79,11 @@ EventCallback<MouseEventArgs> Event occurs when the user clicks on an element. + + OnFocus + EventCallback<FocusEventArgs> + Event occurs when the user focuses on an element. + OnClickStopPropagation Boolean diff --git a/src/MatBlazor/Components/MatButton/BaseMatButton.cs b/src/MatBlazor/Components/MatButton/BaseMatButton.cs index df45f3a2..d4aa16da 100644 --- a/src/MatBlazor/Components/MatButton/BaseMatButton.cs +++ b/src/MatBlazor/Components/MatButton/BaseMatButton.cs @@ -43,6 +43,12 @@ public BaseMatButton() [Parameter] public bool OnClickStopPropagation { get; set; } + /// + /// Event occurs when the user focuses on an element + /// + [Parameter] + public EventCallback OnFocus { get; set; } + /// /// Command executed when the user clicks on an element. /// @@ -197,6 +203,15 @@ protected void OnClickHandler(MouseEventArgs ev) } } + /// + /// Event handler for focus event + /// + /// + protected void OnFocusHandler(FocusEventArgs ev) + { + OnFocus.InvokeAsync(ev); + } + private bool _raised; private bool _unelevated; private bool _outlined; diff --git a/src/MatBlazor/Components/MatButton/MatButton.razor b/src/MatBlazor/Components/MatButton/MatButton.razor index ee86a4f7..0955e1f0 100644 --- a/src/MatBlazor/Components/MatButton/MatButton.razor +++ b/src/MatBlazor/Components/MatButton/MatButton.razor @@ -1,7 +1,7 @@ @namespace MatBlazor @inherits BaseMatButton -