summaryrefslogtreecommitdiff
path: root/Pages/Component/Dialog.razor
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2023-09-08 02:26:32 +1000
committerJake Mannens <jake@asger.xyz>2025-08-20 01:21:04 +1000
commit9d651759bc8757773d89356ad15dba5566e003e1 (patch)
treee96611b11a448f0669776ed8598751c08ea42387 /Pages/Component/Dialog.razor
parent77b904b25aa10129e9d093ec3982642616ae7f31 (diff)
Added framework for routing keyboard events
Diffstat (limited to 'Pages/Component/Dialog.razor')
-rw-r--r--Pages/Component/Dialog.razor19
1 files changed, 18 insertions, 1 deletions
diff --git a/Pages/Component/Dialog.razor b/Pages/Component/Dialog.razor
index dbfec49..673ec2f 100644
--- a/Pages/Component/Dialog.razor
+++ b/Pages/Component/Dialog.razor
@@ -48,6 +48,23 @@
public void Show() => Visible = true;
public void Hide() => Visible = false;
+ protected override async void OnAfterRender(bool firstRender) {
+ if(firstRender) {
+ await jsRuntime.InvokeVoidAsync("dialogAddObjectReference", new object[] {
+ dialogDiv,
+ DotNetObjectReference.Create(this)
+ });
+ }
+ }
+
+ [JSInvokable("KeyHandler")]
+ public void KeyHandler(string key) {
+ if(key == "Escape") {
+ Hide();
+ return;
+ }
+ }
+
private string heightStyle =>
- $"{(height is null ? "" : $"max-height:{height};")}";
+ $"{(height is null ? "" : $"max-height:{height};")}";
}