feat: add recall as internal function to overlay dialog.
This commit is contained in:
@@ -48,5 +48,8 @@
|
||||
</Border>
|
||||
</Grid>
|
||||
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
||||
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
||||
<TextBox u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></TextBox>
|
||||
<u:NumericIntUpDown u:NumPad.Attach="True" Width="100" Watermark="Invoke NumPad"></u:NumericIntUpDown>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
|
||||
@@ -211,6 +211,12 @@ public static class OverlayDialog
|
||||
control.CanLightDismiss = options.CanLightDismiss;
|
||||
control.CanDragMove = options.CanDragMove;
|
||||
}
|
||||
|
||||
|
||||
|
||||
internal static T? Recall<T>(string? hostId) where T: Control
|
||||
{
|
||||
var host = OverlayDialogManager.GetHost(hostId);
|
||||
if (host is null) return null;
|
||||
var item = host.Recall<T>();
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,13 @@ public class NumPad: TemplatedControl
|
||||
|
||||
private static void OnTargetGotFocus(object sender, GotFocusEventArgs e)
|
||||
{
|
||||
if (sender is not InputElement) return;
|
||||
var existing = OverlayDialog.Recall<NumPad>(null);
|
||||
if (existing is not null)
|
||||
{
|
||||
existing.Target = sender as InputElement;
|
||||
return;
|
||||
}
|
||||
var numPad = new NumPad() { Target = sender as InputElement };
|
||||
OverlayDialog.ShowCustom(numPad, new object());
|
||||
}
|
||||
|
||||
@@ -215,7 +215,12 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected override void OnTextInput(TextInputEventArgs e)
|
||||
{
|
||||
_textBox?.RaiseEvent(e);
|
||||
}
|
||||
|
||||
private void OnDragPanelPointerReleased(object sender, PointerReleasedEventArgs e)
|
||||
{
|
||||
_point = null;
|
||||
|
||||
@@ -189,4 +189,10 @@ public partial class OverlayDialogHost: Canvas
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal T? Recall<T>()
|
||||
{
|
||||
var element = _layers.LastOrDefault(a => a.Element.Content?.GetType() == typeof(T));
|
||||
return element?.Element.Content is T t ? t : default;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user