增强 OverlayDialog 和 NumPad 的功能与交互体验
新增 OverlayDialogOptions.OnDialogControlClosed 委托属性, 支持自定义对话框关闭事件处理逻辑,并在 OverlayDialog 中 添加了相关事件绑定与解绑逻辑。 调整 NumPad 的显示与交互逻辑,确保在数字键盘关闭后, 目标输入控件能够重新获取焦点,优化用户体验。
This commit is contained in:
@@ -66,4 +66,8 @@ public class OverlayDialogOptions
|
|||||||
public bool CanResize { get; set; }
|
public bool CanResize { get; set; }
|
||||||
|
|
||||||
public string? StyleClass { get; set; }
|
public string? StyleClass { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
internal Delegate? OnDialogControlClosed { set; get; }
|
||||||
}
|
}
|
||||||
@@ -34,6 +34,18 @@ public static class OverlayDialog
|
|||||||
DataContext = vm,
|
DataContext = vm,
|
||||||
};
|
};
|
||||||
ConfigureDefaultDialogControl(t, options);
|
ConfigureDefaultDialogControl(t, options);
|
||||||
|
|
||||||
|
if (options?.OnDialogControlClosed != null)
|
||||||
|
{
|
||||||
|
t.AddHandler(OverlayShared.OverlayFeedbackElement.ClosedEvent, options.OnDialogControlClosed);
|
||||||
|
|
||||||
|
t.AddHandler(OverlayShared.OverlayFeedbackElement.ClosedEvent, (s,e)=>
|
||||||
|
{
|
||||||
|
if (s is not DialogControlBase control) return;
|
||||||
|
control.RemoveHandler(OverlayShared.OverlayFeedbackElement.ClosedEvent, options.OnDialogControlClosed);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
host.AddDialog(t);
|
host.AddDialog(t);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,14 @@ public class NumPad: TemplatedControl
|
|||||||
Target = sender as InputElement ,
|
Target = sender as InputElement ,
|
||||||
_targetInnerText = FindTextBoxInTarget((sender as InputElement)!)
|
_targetInnerText = FindTextBoxInTarget((sender as InputElement)!)
|
||||||
};
|
};
|
||||||
OverlayDialog.Show(numPad, new object(), options: new OverlayDialogOptions() { Buttons = DialogButton.None });
|
OverlayDialog.Show(numPad, new object(), options: new OverlayDialogOptions()
|
||||||
|
{
|
||||||
|
Buttons = DialogButton.None,
|
||||||
|
OnDialogControlClosed = (object? ss, object? e) =>
|
||||||
|
{
|
||||||
|
numPad.Target?.Focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly Dictionary<Key, string> KeyInputMapping = new()
|
private static readonly Dictionary<Key, string> KeyInputMapping = new()
|
||||||
|
|||||||
Reference in New Issue
Block a user