Skip to content

Commit 42435f8

Browse files
committed
fix: AlertWindow's handleCancel
Signed-off-by: Arufonsu <17498701+Arufonsu@users.noreply.github.com>
1 parent 4891f3c commit 42435f8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Intersect.Client.Core/Interface/Shared/AlertWindow.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public record struct Alert(string Message, string? Title = default, AlertType Ty
2020
public class AlertWindow : InputBox
2121
{
2222
private static readonly HashSet<AlertWindow> _instances = [];
23+
private readonly GwenEventHandler<EventArgs>? _handleCancel;
2324

2425
private AlertWindow(
2526
string title,
@@ -39,6 +40,8 @@ private AlertWindow(
3940
userData: userData
4041
)
4142
{
43+
_handleCancel = handleCancel;
44+
4245
Icon = GameContentManager.Current.GetTexture(
4346
TextureType.Gui,
4447
$"icon.alert.{alertType.ToString().ToLowerInvariant()}.png"
@@ -49,6 +52,15 @@ private AlertWindow(
4952

5053
var titleLabelMargin = TitleLabel.Margin;
5154
TitleLabel.Margin = titleLabelMargin with { Left = titleLabelMargin.Left + 4 };
55+
56+
// Subscribe to the Closed event to handle X button clicks
57+
Closed += OnWindowClosed;
58+
}
59+
60+
private void OnWindowClosed(Base sender, EventArgs args)
61+
{
62+
// Trigger the cancel handler when window is closed via X button
63+
_handleCancel?.Invoke(this, args);
5264
}
5365

5466
protected override void OnCanceled(Base sender, EventArgs args)

0 commit comments

Comments
 (0)