From 7f160489ff134b68c092ba9e15ce5fdd9fa04a8e Mon Sep 17 00:00:00 2001
From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
Date: Sun, 1 Jun 2025 00:06:17 +0800
Subject: [PATCH 1/3] fix: update ClosableTag behavior and styling.
---
src/Ursa.Themes.Semi/Controls/TagInput.axaml | 18 ++++++++++++++----
src/Ursa/Controls/TagInput/ClosableTag.cs | 17 +++++++++--------
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/Ursa.Themes.Semi/Controls/TagInput.axaml b/src/Ursa.Themes.Semi/Controls/TagInput.axaml
index de0526c..3638c06 100644
--- a/src/Ursa.Themes.Semi/Controls/TagInput.axaml
+++ b/src/Ursa.Themes.Semi/Controls/TagInput.axaml
@@ -2,6 +2,9 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
+
+
+
@@ -115,7 +118,7 @@
+ Foreground="{DynamicResource SemiColorText2}"
+ Cursor="Hand" />
+
+
-
+
\ No newline at end of file
diff --git a/src/Ursa/Controls/TagInput/ClosableTag.cs b/src/Ursa/Controls/TagInput/ClosableTag.cs
index de609f2..45980b8 100644
--- a/src/Ursa/Controls/TagInput/ClosableTag.cs
+++ b/src/Ursa/Controls/TagInput/ClosableTag.cs
@@ -8,10 +8,11 @@ using Avalonia.Input;
namespace Ursa.Controls;
[TemplatePart(PART_CloseButton, typeof(PathIcon))]
-public class ClosableTag: ContentControl
+public class ClosableTag : ContentControl
{
public const string PART_CloseButton = "PART_CloseButton";
private PathIcon? _icon;
+
public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(
nameof(Command));
@@ -24,21 +25,21 @@ public class ClosableTag: ContentControl
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
- if (_icon != null)
+ if (_icon is not null)
{
- _icon.PointerPressed -= OnPointerPressed;
+ _icon.PointerReleased -= OnPointerReleased;
}
+
_icon = e.NameScope.Find(PART_CloseButton);
- if (_icon != null)
+ if (_icon is not null)
{
- _icon.PointerPressed += OnPointerPressed;
+ _icon.PointerReleased += OnPointerReleased;
}
-
}
- private void OnPointerPressed(object? sender, PointerPressedEventArgs args)
+ private void OnPointerReleased(object? sender, PointerReleasedEventArgs args)
{
- if (Command != null && Command.CanExecute(null))
+ if (Command is not null && Command.CanExecute(null))
{
Command.Execute(this);
}
From b81d6c69a773d41924646827bf03a6ae299eba3a Mon Sep 17 00:00:00 2001
From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com>
Date: Mon, 2 Jun 2025 02:12:24 +0800
Subject: [PATCH 2/3] feat: replace PathIcon with Button.
---
src/Ursa.Themes.Semi/Controls/TagInput.axaml | 19 ++++++++--------
src/Ursa/Controls/TagInput/ClosableTag.cs | 24 +++-----------------
2 files changed, 13 insertions(+), 30 deletions(-)
diff --git a/src/Ursa.Themes.Semi/Controls/TagInput.axaml b/src/Ursa.Themes.Semi/Controls/TagInput.axaml
index 3638c06..1e865f6 100644
--- a/src/Ursa.Themes.Semi/Controls/TagInput.axaml
+++ b/src/Ursa.Themes.Semi/Controls/TagInput.axaml
@@ -124,16 +124,17 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="3">
-
+ Command="{TemplateBinding Command}"
+ CommandParameter="{TemplateBinding}"
+ Content="{StaticResource ClosableTagCloseIconGlyph}" />
-
-
diff --git a/src/Ursa/Controls/TagInput/ClosableTag.cs b/src/Ursa/Controls/TagInput/ClosableTag.cs
index 45980b8..c37417e 100644
--- a/src/Ursa/Controls/TagInput/ClosableTag.cs
+++ b/src/Ursa/Controls/TagInput/ClosableTag.cs
@@ -3,15 +3,14 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
-using Avalonia.Input;
namespace Ursa.Controls;
-[TemplatePart(PART_CloseButton, typeof(PathIcon))]
+[TemplatePart(PART_CloseButton, typeof(Button))]
public class ClosableTag : ContentControl
{
public const string PART_CloseButton = "PART_CloseButton";
- private PathIcon? _icon;
+ private Button? _closeButton;
public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(
nameof(Command));
@@ -25,23 +24,6 @@ public class ClosableTag : ContentControl
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
- if (_icon is not null)
- {
- _icon.PointerReleased -= OnPointerReleased;
- }
-
- _icon = e.NameScope.Find(PART_CloseButton);
- if (_icon is not null)
- {
- _icon.PointerReleased += OnPointerReleased;
- }
- }
-
- private void OnPointerReleased(object? sender, PointerReleasedEventArgs args)
- {
- if (Command is not null && Command.CanExecute(null))
- {
- Command.Execute(this);
- }
+ _closeButton = e.NameScope.Find