Add FieldCursor parameter for customizable cursor styles

Introduced a `FieldCursor` parameter in the `SenderPdfImageEditor`
component to allow customization of the cursor style for fields,
defaulting to `"move"`. Updated the `GetFieldStyle` method to
include this parameter and apply the cursor style dynamically.

Modified the `foreach` loop in `SenderPdfImageEditor.razor` to
pass the `FieldCursor` parameter when rendering fields. Added
a `cursor` CSS property to the inline styles generated by
`GetFieldStyle`.

Updated `ReceiverPage.razor` to pass `"pointer"` as the
`FieldCursor` value to `SenderPdfImageEditor`. Also added
`@onclick:stopPropagation` to prevent click event propagation
from field elements.
This commit is contained in:
2026-11-24 11:49:56 +01:00
parent e65531db57
commit 4fc00e02e7
2 changed files with 15 additions and 9 deletions

View File

@@ -84,14 +84,14 @@
<div class="sender-image-editor__page-placeholder">@L("SenderEditor_PageLabel", "Seite") @pageNumber</div>
}
@foreach (var field in Fields.Where(f => f.Page == pageNumber))
{
<div class="sender-image-editor__field"
style="@GetFieldStyle(field, widthPt, heightPt)"
title="@field.ReceiverName"
@onmousedown="args => OnFieldMouseDownAsync(args, field)"
@onmousedown:preventDefault="true"
@onclick="() => OnFieldClickAsync(field.Index)"
@foreach (var field in Fields.Where(f => f.Page == pageNumber))
{
<div class="sender-image-editor__field"
style="@GetFieldStyle(field, widthPt, heightPt, FieldCursor)"
title="@field.ReceiverName"
@onmousedown="args => OnFieldMouseDownAsync(args, field)"
@onmousedown:preventDefault="true"
@onclick="() => OnFieldClickAsync(field.Index)"
@onclick:stopPropagation="true">
<span class="sender-image-editor__field-label">@field.ReceiverName</span>
@if (ShowFieldRemoveButton)
@@ -175,6 +175,9 @@
[Parameter]
public EventCallback<int> FieldClick { get; set; }
[Parameter]
public string FieldCursor { get; set; } = "move";
private int? _draggedFieldIndex;
private bool _isDragging;
private double _grabOffsetXPt;
@@ -191,12 +194,13 @@
private bool CanDownloadPdf => !string.IsNullOrWhiteSpace(PdfDataUrl);
private bool CanPrintPdf => !string.IsNullOrWhiteSpace(PdfDataUrl);
private static string GetFieldStyle(SenderPdfFieldOverlay field, double pageWidthPt, double pageHeightPt)
private static string GetFieldStyle(SenderPdfFieldOverlay field, double pageWidthPt, double pageHeightPt, string fieldCursor)
{
var leftPercent = (field.XPt / pageWidthPt) * 100.0;
var topPercent = (field.YPt / pageHeightPt) * 100.0;
var widthPercent = (127.44 / pageWidthPt) * 100.0;
var heightPercent = (141.12 / pageHeightPt) * 100.0;
var cursor = string.IsNullOrWhiteSpace(fieldCursor) ? "move" : fieldCursor;
var left = leftPercent.ToString("F4", CultureInfo.InvariantCulture);
var top = topPercent.ToString("F4", CultureInfo.InvariantCulture);
@@ -218,6 +222,7 @@
"padding:0.2rem 0.3rem;",
"overflow:hidden;",
"z-index:30;",
$"cursor:{cursor};",
$"border-color:{field.Color};",
$"background-color:{field.Color}22;");
}

View File

@@ -210,6 +210,7 @@
PdfFileName="@PdfFileName"
Fields="@VisibleFieldOverlays"
SignatureOverlays="@SignedOverlays"
FieldCursor="pointer"
FieldClick="OnSignatureFieldClickAsync"
ShowFieldRemoveButton="false" />
}