-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added
TriggerEvent
method to make it easier to trigger custom…
… events. closes #341
- Loading branch information
Showing
6 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
tests/bunit.testassets/SampleComponents/CustomPasteSample.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p>Try pasting into the following text box:</p> | ||
<input @oncustompaste="HandleCustomPaste" /> | ||
<p>@message</p> |
30 changes: 30 additions & 0 deletions
30
tests/bunit.testassets/SampleComponents/CustomPasteSample.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace Bunit.TestAssets.SampleComponents | ||
{ | ||
public partial class CustomPasteSample | ||
{ | ||
string message = string.Empty; | ||
|
||
void HandleCustomPaste(CustomPasteEventArgs eventArgs) | ||
{ | ||
message = $"You pasted: {eventArgs.PastedData}"; | ||
} | ||
} | ||
|
||
[EventHandler("oncustompaste", typeof(CustomPasteEventArgs), enableStopPropagation: true, enablePreventDefault: true)] | ||
public static class EventHandlers | ||
{ | ||
// This static class doesn't need to contain any members. It's just a place where we can put | ||
// [EventHandler] attributes to configure event types on the Razor compiler. This affects the | ||
// compiler output as well as code completions in the editor. | ||
} | ||
|
||
public class CustomPasteEventArgs : EventArgs | ||
{ | ||
// Data for these properties will be supplied by custom JavaScript logic | ||
public DateTime EventTimestamp { get; set; } | ||
public string PastedData { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters