Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added OnClick and OnMouse actions for Canvas #84

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Blazor.Extensions.Canvas/BECanvas.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
@inherits BECanvasComponent

<canvas id="@Id" width="@Width" height="@Height" @ref="_canvasRef"></canvas>
<canvas id="@Id" width="@Width" height="@Height" @ref="_canvasRef"
onclick="@OnClick"
oncontextmenu="@OnContextMenu"
ondblclick="@OnDblClick"
onmousedown="@OnMouseDown"
onmousemove="@OnMouseMove"
onmouseout="@OnMouseOut"
onmouseover="@OnMouseOver"
onmouseup="@OnMouseUp"
onmousewheel="@OnMouseWheel"
onpointerdown="@OnPointerDown"
onpointerup="@OnPointerUp"
onpointermove="@OnPointerMove" ></canvas>
37 changes: 37 additions & 0 deletions src/Blazor.Extensions.Canvas/BECanvasComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.JSInterop;
using System;

Expand All @@ -12,6 +13,42 @@ public class BECanvasComponent : ComponentBase
[Parameter]
public long Width { get; set; }

[Parameter]
public Action<MouseEventArgs> OnClick { get; set; }

[Parameter]
public Action<MouseEventArgs> OnContextMenu { get; set; }

[Parameter]
public Action<MouseEventArgs> OnDblClick { get; set; }

[Parameter]
public Action<MouseEventArgs> OnMouseDown { get; set; }

[Parameter]
public Action<MouseEventArgs> OnMouseMove { get; set; }

[Parameter]
public Action<MouseEventArgs> OnMouseOut { get; set; }

[Parameter]
public Action<MouseEventArgs> OnMouseOver { get; set; }

[Parameter]
public Action<MouseEventArgs> OnMouseUp { get; set; }

[Parameter]
public Action<MouseEventArgs> OnMouseWheel { get; set; }

[Parameter]
public Action<PointerEventArgs> OnPointerDown { get; set; }

[Parameter]
public Action<PointerEventArgs> OnPointerUp { get; set; }

[Parameter]
public Action<PointerEventArgs> OnPointerMove { get; set; }

protected readonly string Id = Guid.NewGuid().ToString();
protected ElementReference _canvasRef;

Expand Down
Loading