feat: make mode a flag.
This commit is contained in:
@@ -190,7 +190,7 @@ public class PopConfirm : ContentControl
|
|||||||
void OnCanExecuteChanged(object? _, System.EventArgs a)
|
void OnCanExecuteChanged(object? _, System.EventArgs a)
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
if (count != 2) return;
|
if (count < 1) return;
|
||||||
var canExecute = command.CanExecute(button.CommandParameter);
|
var canExecute = command.CanExecute(button.CommandParameter);
|
||||||
if (canExecute)
|
if (canExecute)
|
||||||
{
|
{
|
||||||
@@ -225,14 +225,14 @@ public class PopConfirm : ContentControl
|
|||||||
private void SetupChildrenEventSubscriptions(Control? child, PopConfirmTriggerMode mode)
|
private void SetupChildrenEventSubscriptions(Control? child, PopConfirmTriggerMode mode)
|
||||||
{
|
{
|
||||||
if (child is null) return;
|
if (child is null) return;
|
||||||
if (mode == PopConfirmTriggerMode.Click)
|
if (mode.HasFlag(PopConfirmTriggerMode.Click))
|
||||||
{
|
{
|
||||||
if (child is Button button)
|
if (child is Button button)
|
||||||
Button.ClickEvent.AddHandler(OnMainButtonClicked, button);
|
Button.ClickEvent.AddHandler(OnMainButtonClicked, button);
|
||||||
else
|
else
|
||||||
PointerPressedEvent.AddHandler(OnMainElementPressed, child);
|
PointerPressedEvent.AddHandler(OnMainElementPressed, child);
|
||||||
}
|
}
|
||||||
else if (mode == PopConfirmTriggerMode.Focus)
|
if (mode.HasFlag(PopConfirmTriggerMode.Focus))
|
||||||
{
|
{
|
||||||
GotFocusEvent.AddHandler(OnMainElementGotFocus, child);
|
GotFocusEvent.AddHandler(OnMainElementGotFocus, child);
|
||||||
LostFocusEvent.AddHandler(OnMainElementLostFocus, child);
|
LostFocusEvent.AddHandler(OnMainElementLostFocus, child);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
public enum PopConfirmTriggerMode
|
public enum PopConfirmTriggerMode
|
||||||
{
|
{
|
||||||
Click,
|
Click,
|
||||||
|
|||||||
Reference in New Issue
Block a user