protected override void BuildRenderTree(RenderTreeBuilder builder) { /* * <div onclick="@(MouseButtonTrigger == MouseButtonTrigger.Left || MouseButtonTrigger == MouseButtonTrigger.Both ? $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'","\\'")}'); " : "")" * oncontextmenu="@(MouseButtonTrigger == MouseButtonTrigger.Right || MouseButtonTrigger == MouseButtonTrigger.Both ? $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'","\\'")}');": "")" * class="@CssClass"> @ChildContent * </div> */ builder.OpenElement(0, WrapperTag); if (MouseButtonTrigger == MouseButtonTrigger.Left || MouseButtonTrigger == MouseButtonTrigger.Both) { builder.AddAttribute(1, "onclick", EventCallback.Factory.Create <UIMouseEventArgs>(this, $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'", "\\'")}');")); } if (MouseButtonTrigger == MouseButtonTrigger.Right || MouseButtonTrigger == MouseButtonTrigger.Both) { builder.AddAttribute(2, "oncontextmenu", EventCallback.Factory.Create <UIMouseEventArgs>(this, $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'", "\\'")}');")); } if (MouseButtonTrigger == MouseButtonTrigger.DoubleClick) { builder.AddAttribute(3, "ondblclick", EventCallback.Factory.Create <UIMouseEventArgs>(this, $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'", "\\'")}');")); } builder.AddAttribute(4, "class", CssClass); builder.AddAttribute(5, "id", Id); builder.AddContent(6, ChildContent); builder.CloseElement(); }
protected override void BuildRenderTree(RenderTreeBuilder builder) { /* * <div @attributes="Attributes" * onclick="@(MouseButtonTrigger == MouseButtonTrigger.Left || MouseButtonTrigger == MouseButtonTrigger.Both ? $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'","\\'")}'); " : "")" * ondblclick="@(MouseButtonTrigger == MouseButtonTrigger.DoubleClick ? $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'","\\'")}'); " : "")" * oncontextmenu="@(MouseButtonTrigger == MouseButtonTrigger.Right || MouseButtonTrigger == MouseButtonTrigger.Both ? $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'","\\'")}');": "")" * class="@CssClass"> * @ChildContent * </div> */ builder.OpenElement(0, WrapperTag); builder.AddMultipleAttributes(1, Microsoft.AspNetCore.Components.CompilerServices.RuntimeHelpers.TypeCheck <global::System.Collections.Generic.IEnumerable <global::System.Collections.Generic.KeyValuePair <string, object> > >(Attributes)); if (MouseButtonTrigger == MouseButtonTrigger.Left || MouseButtonTrigger == MouseButtonTrigger.Both) { builder.AddAttribute(2, "onclick", $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'", "\\'")}', {StopPropagation.ToString().ToLower()});"); } if (MouseButtonTrigger == MouseButtonTrigger.Right || MouseButtonTrigger == MouseButtonTrigger.Both) { builder.AddAttribute(3, "oncontextmenu", $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'", "\\'")}', {StopPropagation.ToString().ToLower()});"); } if (MouseButtonTrigger == MouseButtonTrigger.DoubleClick) { builder.AddAttribute(4, "ondblclick", $"blazorContextMenu.OnContextMenu(event, '{MenuId.Replace("'", "\\'")}', {StopPropagation.ToString().ToLower()});"); } if (!string.IsNullOrWhiteSpace(CssClass)) { builder.AddAttribute(5, "class", CssClass); } builder.AddAttribute(6, "id", Id); builder.AddContent(7, ChildContent); builder.AddElementReferenceCapture(8, (__value) => { contextMenuTriggerElementRef = __value; }); builder.CloseElement(); }