feat: make mode a flag.

This commit is contained in:
Dong Bin
2025-04-18 19:39:13 +08:00
parent 8eaafee693
commit a01d36ceb3
2 changed files with 4 additions and 3 deletions

View File

@@ -190,7 +190,7 @@ public class PopConfirm : ContentControl
void OnCanExecuteChanged(object? _, System.EventArgs a)
{
count++;
if (count != 2) return;
if (count < 1) return;
var canExecute = command.CanExecute(button.CommandParameter);
if (canExecute)
{
@@ -225,14 +225,14 @@ public class PopConfirm : ContentControl
private void SetupChildrenEventSubscriptions(Control? child, PopConfirmTriggerMode mode)
{
if (child is null) return;
if (mode == PopConfirmTriggerMode.Click)
if (mode.HasFlag(PopConfirmTriggerMode.Click))
{
if (child is Button button)
Button.ClickEvent.AddHandler(OnMainButtonClicked, button);
else
PointerPressedEvent.AddHandler(OnMainElementPressed, child);
}
else if (mode == PopConfirmTriggerMode.Focus)
if (mode.HasFlag(PopConfirmTriggerMode.Focus))
{
GotFocusEvent.AddHandler(OnMainElementGotFocus, child);
LostFocusEvent.AddHandler(OnMainElementLostFocus, child);

View File

@@ -1,5 +1,6 @@
namespace Ursa.Controls;
[Flags]
public enum PopConfirmTriggerMode
{
Click,