From fdcd35ba39d67894f9d5219fea338afb0a93dd6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20B=C5=82a=C5=BCejewicz=20=28Peter=20Blazejewicz=29?= Date: Tue, 29 Oct 2019 23:19:36 +0100 Subject: [PATCH] Expose OnFocus event on MatButton. Closes #314 - implementation change - example code update Thanks! --- src/MatBlazor.Demo/Demo/DemoMatButton.razor | 14 ++++++++++++-- src/MatBlazor.Demo/Doc/DocMatButton.razor | 5 +++++ .../Components/MatButton/BaseMatButton.cs | 15 +++++++++++++++ .../Components/MatButton/MatButton.razor | 2 +- src/MatBlazor/MatBlazor.xml | 11 +++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) 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 -