Skip to content

Commit e0de73a

Browse files
authored
Fixes #4023 - Changes CommandEventArgs to be based on HandledEventArgs instead of CancelEventArgs (#4054)
* touching publish.yml * CancelEventArgs->HandledEventArgs * Fixed Handled issues
1 parent f98e460 commit e0de73a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+261
-229
lines changed

Examples/CommunityToolkitExample/LoginView.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public LoginView (LoginViewModel viewModel)
2323
{
2424
if (!ViewModel.CanLogin) { return; }
2525
ViewModel.LoginCommand.Execute (null);
26-
// Anytime Accepting is handled, make sure to set e.Cancel to false.
27-
e.Cancel = false;
26+
// When Accepting is handled, set e.Handled to true to prevent further processing.
27+
e.Handled = true;
2828
};
2929

3030
clearButton.Accepting += (_, e) =>
3131
{
3232
ViewModel.ClearCommand.Execute (null);
33-
// Anytime Accepting is handled, make sure to set e.Cancel to false.
34-
e.Cancel = false;
33+
// When Accepting is handled, set e.Handled to true to prevent further processing.
34+
e.Handled = true;
3535
};
3636

3737
Initialized += (_, _) => { ViewModel.Initialized (); };

Examples/Example/Example.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public ExampleWindow ()
7878
{
7979
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
8080
}
81-
// Anytime Accepting is handled, make sure to set e.Cancel to false.
82-
e.Cancel = false;
81+
// When Accepting is handled, set e.Handled to true to prevent further processing.
82+
e.Handled = true;
8383
};
8484

8585
// Add the views to the Window

Examples/NativeAot/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public ExampleWindow ()
105105
{
106106
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
107107
}
108-
// Anytime Accepting is handled, make sure to set e.Cancel to false.
109-
e.Cancel = false;
108+
// Anytime Accepting is handled, make sure to set e.Handled to true.
109+
e.Handled = true;
110110
};
111111

112112
// Add the views to the Window

Examples/ReactiveExample/LoginViewModel.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Threading.Tasks;
77
using ReactiveUI;
88
using ReactiveUI.SourceGenerators;
9+
using Terminal.Gui;
910

1011
namespace ReactiveExample;
1112

@@ -50,7 +51,7 @@ public LoginViewModel ()
5051

5152
_isValidHelper = canLogin.ToProperty (this, x => x.IsValid);
5253

53-
Login = ReactiveCommand.CreateFromTask<HandledEventArgs>
54+
Login = ReactiveCommand.CreateFromTask<CommandEventArgs>
5455
(
5556
e => Task.Delay (TimeSpan.FromSeconds (1)),
5657
canLogin
@@ -76,8 +77,8 @@ public LoginViewModel ()
7677
}
7778

7879
[ReactiveCommand]
79-
public void Clear (HandledEventArgs args) { }
80+
public void Clear (CommandEventArgs args) { }
8081

8182
[IgnoreDataMember]
82-
public ReactiveCommand<HandledEventArgs, Unit> Login { get; }
83+
public ReactiveCommand<CommandEventArgs, Unit> Login { get; }
8384
}

Examples/SelfContained/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public ExampleWindow ()
104104
{
105105
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
106106
}
107-
// Anytime Accepting is handled, make sure to set e.Cancel to false.
108-
e.Cancel = false;
107+
// When Accepting is handled, set e.Handled to true to prevent further processing.
108+
e.Handled = true;
109109
};
110110

111111
// Add the views to the Window

Examples/UICatalog/Scenarios/Adornments.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public override void Main ()
143143
view.Border.CloseButton.Accept += (s, e) =>
144144
{
145145
MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
146-
e.Cancel = true;
146+
e.Handled = true;
147147
};
148148

149149
view.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");

Examples/UICatalog/Scenarios/AllViewsTester.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public override void Main ()
8383
_classListView.Accepting += (sender, args) =>
8484
{
8585
_curView?.SetFocus ();
86-
args.Cancel = true;
86+
args.Handled = true;
8787
};
8888

8989
_adornmentsEditor = new ()

Examples/UICatalog/Scenarios/Bars.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ private void ConfigureMenu (Bar bar)
486486
CanFocus = false
487487
};
488488
// This ensures the checkbox state toggles when the hotkey of Title is pressed.
489-
shortcut4.Accepting += (sender, args) => args.Cancel = true;
489+
shortcut4.Accepting += (sender, args) => args.Handled = true;
490490

491491
bar.Add (shortcut1, shortcut2, shortcut3, line, shortcut4);
492492
}
@@ -536,7 +536,7 @@ public void ConfigStatusBar (Bar bar)
536536
{
537537
button1.Visible = !button1.Visible;
538538
button1.Enabled = button1.Visible;
539-
e.Cancel = false;
539+
e.Handled = true;
540540
};
541541

542542
bar.Add (new Label

Examples/UICatalog/Scenarios/Buttons.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ public override void Main ()
4949

5050
swapButton.Accepting += (s, e) =>
5151
{
52-
e.Cancel = !swapButton.IsDefault;
52+
e.Handled = !swapButton.IsDefault;
5353
defaultButton.IsDefault = !defaultButton.IsDefault;
5454
swapButton.IsDefault = !swapButton.IsDefault;
5555
};
5656

5757
defaultButton.Accepting += (s, e) =>
5858
{
59-
e.Cancel = !defaultButton.IsDefault;
59+
e.Handled = !defaultButton.IsDefault;
6060

61-
if (e.Cancel)
61+
if (e.Handled)
6262
{
6363
MessageBox.ErrorQuery ("Error", "This button is no longer the Quit button; the Swap Default button is.", "_Ok");
6464
}
@@ -71,7 +71,7 @@ static void DoMessage (Button button, string txt)
7171
{
7272
string btnText = button.Text;
7373
MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
74-
e.Cancel = true;
74+
e.Handled = true;
7575
};
7676
}
7777

@@ -114,15 +114,15 @@ static void DoMessage (Button button, string txt)
114114
button.Accepting += (s, e) =>
115115
{
116116
MessageBox.Query ("Message", "Question?", "Yes", "No");
117-
e.Cancel = true;
117+
e.Handled = true;
118118
};
119119

120120
var textChanger = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "Te_xt Changer" };
121121
main.Add (textChanger);
122122
textChanger.Accepting += (s, e) =>
123123
{
124124
textChanger.Text += "!";
125-
e.Cancel = true;
125+
e.Handled = true;
126126
};
127127

128128
main.Add (
@@ -133,7 +133,7 @@ static void DoMessage (Button button, string txt)
133133
Text = "Lets see if this will move as \"Text Changer\" grows"
134134
}
135135
);
136-
button.Accepting += (sender, args) => { args.Cancel = true; };
136+
button.Accepting += (sender, args) => { args.Handled = true; };
137137

138138
var removeButton = new Button
139139
{
@@ -146,7 +146,7 @@ static void DoMessage (Button button, string txt)
146146
removeButton.Accepting += (s, e) =>
147147
{
148148
removeButton.Visible = false;
149-
e.Cancel = true;
149+
e.Handled = true;
150150
};
151151

152152
var computedFrame = new FrameView
@@ -172,7 +172,7 @@ static void DoMessage (Button button, string txt)
172172
moveBtn.Accepting += (s, e) =>
173173
{
174174
moveBtn.X = moveBtn.Frame.X + 5;
175-
e.Cancel = true;
175+
e.Handled = true;
176176
};
177177
computedFrame.Add (moveBtn);
178178

@@ -189,7 +189,7 @@ static void DoMessage (Button button, string txt)
189189
sizeBtn.Accepting += (s, e) =>
190190
{
191191
sizeBtn.Width = sizeBtn.Frame.Width + 5;
192-
e.Cancel = true;
192+
e.Handled = true;
193193
};
194194
computedFrame.Add (sizeBtn);
195195

@@ -214,7 +214,7 @@ static void DoMessage (Button button, string txt)
214214
moveBtnA.Frame.Width,
215215
moveBtnA.Frame.Height
216216
);
217-
e.Cancel = true;
217+
e.Handled = true;
218218
};
219219
absoluteFrame.Add (moveBtnA);
220220

@@ -232,7 +232,7 @@ static void DoMessage (Button button, string txt)
232232
sizeBtnA.Frame.Width + 5,
233233
sizeBtnA.Frame.Height
234234
);
235-
e.Cancel = true;
235+
e.Handled = true;
236236
};
237237
absoluteFrame.Add (sizeBtnA);
238238

@@ -300,7 +300,7 @@ string MoveHotkey (string txt)
300300
moveHotKeyBtn.Accepting += (s, e) =>
301301
{
302302
moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text);
303-
e.Cancel = true;
303+
e.Handled = true;
304304
};
305305
main.Add (moveHotKeyBtn);
306306

@@ -317,7 +317,7 @@ string MoveHotkey (string txt)
317317
moveUnicodeHotKeyBtn.Accepting += (s, e) =>
318318
{
319319
moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text);
320-
e.Cancel = true;
320+
e.Handled = true;
321321
};
322322
main.Add (moveUnicodeHotKeyBtn);
323323

@@ -401,7 +401,7 @@ void NumericUpDown_ValueChanged (object sender, EventArgs<int> e) { }
401401
noRepeatButton.Accepting += (s, e) =>
402402
{
403403
noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}";
404-
e.Cancel = true;
404+
e.Handled = true;
405405
};
406406
main.Add (label, noRepeatButton);
407407

@@ -423,7 +423,7 @@ void NumericUpDown_ValueChanged (object sender, EventArgs<int> e) { }
423423
repeatButton.Accepting += (s, e) =>
424424
{
425425
repeatButton.Title = $"Accept Co_unt: {++acceptCount}";
426-
e.Cancel = true;
426+
e.Handled = true;
427427
};
428428

429429
var enableCB = new CheckBox

Examples/UICatalog/Scenarios/CharacterMap/CharacterMap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void JumpEditOnAccept (object? sender, CommandEventArgs e)
256256
_charMap.SetFocus ();
257257

258258
// Cancel the event to prevent ENTER from being handled elsewhere
259-
e.Cancel = true;
259+
e.Handled = true;
260260
}
261261
}
262262

0 commit comments

Comments
 (0)