Skip to content

Fixes #4023 - Changes CommandEventArgs to be based on HandledEventArgs instead of CancelEventArgs #4054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b0f050f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 21, 2025
a64b4bc
touching publish.yml
tig Mar 21, 2025
320384e
Merge branch 'v2_release' into v2_develop
tig Mar 21, 2025
4048436
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Mar 29, 2025
3b0311d
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 29, 2025
ae79c48
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Mar 30, 2025
1c39896
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 1, 2025
2cee67f
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 1, 2025
9560cf3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 2, 2025
0795dd1
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 2, 2025
4baccd7
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 3, 2025
7d7ffad
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 5, 2025
c37210a
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 5, 2025
680e5ae
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 16, 2025
3cba0a5
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 23, 2025
9bbec08
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 24, 2025
64403fa
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 24, 2025
5e1251c
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 24, 2025
49cd335
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
9a8e4e3
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 25, 2025
ef6d193
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
4c0c504
Merge branch 'gui-cs:v2_develop' into v2_develop
tig Apr 25, 2025
6d4cfe5
Merge branch 'v2_develop' of tig:tig/Terminal.Gui into v2_develop
tig Apr 25, 2025
0e794b8
CancelEventArgs->HandledEventArgs
tig Apr 25, 2025
c1afaf6
Fixed Handled issues
tig Apr 25, 2025
c2474d6
Merge branch 'v2_develop' into v2_4023-CommandEventArgs_Handled
tig Apr 28, 2025
5c101dc
Merge branch 'v2_develop' into v2_4023-CommandEventArgs_Handled
tig May 6, 2025
ab1fe7c
Merge branch 'v2_develop' into v2_4023-CommandEventArgs_Handled
tig May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Examples/CommunityToolkitExample/LoginView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public LoginView (LoginViewModel viewModel)
{
if (!ViewModel.CanLogin) { return; }
ViewModel.LoginCommand.Execute (null);
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = false;
// When Accepting is handled, set e.Handled to true to prevent further processing.
e.Handled = true;
};

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

Initialized += (_, _) => { ViewModel.Initialized (); };
Expand Down
4 changes: 2 additions & 2 deletions Examples/Example/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public ExampleWindow ()
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = false;
// When Accepting is handled, set e.Handled to true to prevent further processing.
e.Handled = true;
};

// Add the views to the Window
Expand Down
4 changes: 2 additions & 2 deletions Examples/NativeAot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public ExampleWindow ()
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = false;
// Anytime Accepting is handled, make sure to set e.Handled to true.
e.Handled = true;
};

// Add the views to the Window
Expand Down
7 changes: 4 additions & 3 deletions Examples/ReactiveExample/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using ReactiveUI;
using ReactiveUI.SourceGenerators;
using Terminal.Gui;

namespace ReactiveExample;

Expand Down Expand Up @@ -50,7 +51,7 @@ public LoginViewModel ()

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

Login = ReactiveCommand.CreateFromTask<HandledEventArgs>
Login = ReactiveCommand.CreateFromTask<CommandEventArgs>
(
e => Task.Delay (TimeSpan.FromSeconds (1)),
canLogin
Expand All @@ -76,8 +77,8 @@ public LoginViewModel ()
}

[ReactiveCommand]
public void Clear (HandledEventArgs args) { }
public void Clear (CommandEventArgs args) { }

[IgnoreDataMember]
public ReactiveCommand<HandledEventArgs, Unit> Login { get; }
public ReactiveCommand<CommandEventArgs, Unit> Login { get; }
}
4 changes: 2 additions & 2 deletions Examples/SelfContained/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public ExampleWindow ()
{
MessageBox.ErrorQuery ("Logging In", "Incorrect username or password", "Ok");
}
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = false;
// When Accepting is handled, set e.Handled to true to prevent further processing.
e.Handled = true;
};

// Add the views to the Window
Expand Down
2 changes: 1 addition & 1 deletion Examples/UICatalog/Scenarios/Adornments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public override void Main ()
view.Border.CloseButton.Accept += (s, e) =>
{
MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
e.Cancel = true;
e.Handled = true;
};

view.Accept += (s, e) => MessageBox.Query (20, 7, "Hi", "Window Close Button Pressed!", "Ok");
Expand Down
2 changes: 1 addition & 1 deletion Examples/UICatalog/Scenarios/AllViewsTester.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override void Main ()
_classListView.Accepting += (sender, args) =>
{
_curView?.SetFocus ();
args.Cancel = true;
args.Handled = true;
};

_adornmentsEditor = new ()
Expand Down
4 changes: 2 additions & 2 deletions Examples/UICatalog/Scenarios/Bars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ private void ConfigureMenu (Bar bar)
CanFocus = false
};
// This ensures the checkbox state toggles when the hotkey of Title is pressed.
shortcut4.Accepting += (sender, args) => args.Cancel = true;
shortcut4.Accepting += (sender, args) => args.Handled = true;

bar.Add (shortcut1, shortcut2, shortcut3, line, shortcut4);
}
Expand Down Expand Up @@ -536,7 +536,7 @@ public void ConfigStatusBar (Bar bar)
{
button1.Visible = !button1.Visible;
button1.Enabled = button1.Visible;
e.Cancel = false;
e.Handled = true;
};

bar.Add (new Label
Expand Down
32 changes: 16 additions & 16 deletions Examples/UICatalog/Scenarios/Buttons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ public override void Main ()

swapButton.Accepting += (s, e) =>
{
e.Cancel = !swapButton.IsDefault;
e.Handled = !swapButton.IsDefault;
defaultButton.IsDefault = !defaultButton.IsDefault;
swapButton.IsDefault = !swapButton.IsDefault;
};

defaultButton.Accepting += (s, e) =>
{
e.Cancel = !defaultButton.IsDefault;
e.Handled = !defaultButton.IsDefault;

if (e.Cancel)
if (e.Handled)
{
MessageBox.ErrorQuery ("Error", "This button is no longer the Quit button; the Swap Default button is.", "_Ok");
}
Expand All @@ -71,7 +71,7 @@ static void DoMessage (Button button, string txt)
{
string btnText = button.Text;
MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
e.Cancel = true;
e.Handled = true;
};
}

Expand Down Expand Up @@ -114,15 +114,15 @@ static void DoMessage (Button button, string txt)
button.Accepting += (s, e) =>
{
MessageBox.Query ("Message", "Question?", "Yes", "No");
e.Cancel = true;
e.Handled = true;
};

var textChanger = new Button { X = 2, Y = Pos.Bottom (button) + 1, Text = "Te_xt Changer" };
main.Add (textChanger);
textChanger.Accepting += (s, e) =>
{
textChanger.Text += "!";
e.Cancel = true;
e.Handled = true;
};

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

var removeButton = new Button
{
Expand All @@ -146,7 +146,7 @@ static void DoMessage (Button button, string txt)
removeButton.Accepting += (s, e) =>
{
removeButton.Visible = false;
e.Cancel = true;
e.Handled = true;
};

var computedFrame = new FrameView
Expand All @@ -172,7 +172,7 @@ static void DoMessage (Button button, string txt)
moveBtn.Accepting += (s, e) =>
{
moveBtn.X = moveBtn.Frame.X + 5;
e.Cancel = true;
e.Handled = true;
};
computedFrame.Add (moveBtn);

Expand All @@ -189,7 +189,7 @@ static void DoMessage (Button button, string txt)
sizeBtn.Accepting += (s, e) =>
{
sizeBtn.Width = sizeBtn.Frame.Width + 5;
e.Cancel = true;
e.Handled = true;
};
computedFrame.Add (sizeBtn);

Expand All @@ -214,7 +214,7 @@ static void DoMessage (Button button, string txt)
moveBtnA.Frame.Width,
moveBtnA.Frame.Height
);
e.Cancel = true;
e.Handled = true;
};
absoluteFrame.Add (moveBtnA);

Expand All @@ -232,7 +232,7 @@ static void DoMessage (Button button, string txt)
sizeBtnA.Frame.Width + 5,
sizeBtnA.Frame.Height
);
e.Cancel = true;
e.Handled = true;
};
absoluteFrame.Add (sizeBtnA);

Expand Down Expand Up @@ -300,7 +300,7 @@ string MoveHotkey (string txt)
moveHotKeyBtn.Accepting += (s, e) =>
{
moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text);
e.Cancel = true;
e.Handled = true;
};
main.Add (moveHotKeyBtn);

Expand All @@ -317,7 +317,7 @@ string MoveHotkey (string txt)
moveUnicodeHotKeyBtn.Accepting += (s, e) =>
{
moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text);
e.Cancel = true;
e.Handled = true;
};
main.Add (moveUnicodeHotKeyBtn);

Expand Down Expand Up @@ -401,7 +401,7 @@ void NumericUpDown_ValueChanged (object sender, EventArgs<int> e) { }
noRepeatButton.Accepting += (s, e) =>
{
noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}";
e.Cancel = true;
e.Handled = true;
};
main.Add (label, noRepeatButton);

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

var enableCB = new CheckBox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void JumpEditOnAccept (object? sender, CommandEventArgs e)
_charMap.SetFocus ();

// Cancel the event to prevent ENTER from being handled elsewhere
e.Cancel = true;
e.Handled = true;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Examples/UICatalog/Scenarios/Dialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public override void Main ()
);
Application.Run (dlg);
dlg.Dispose ();
e.Cancel = true;
e.Handled = true;
};

app.Add (showDialogButton);
Expand Down Expand Up @@ -258,7 +258,7 @@ Label buttonPressedLabel
button.Accepting += (s, e) =>
{
clicked = buttonId;
e.Cancel = true;
e.Handled = true;
Application.RequestStop ();
};
buttons.Add (button);
Expand Down Expand Up @@ -313,7 +313,7 @@ Label buttonPressedLabel
{
clicked = buttonId;
Application.RequestStop ();
e.Cancel = true;
e.Handled = true;
};
buttons.Add (button);
dialog.AddButton (button);
Expand All @@ -322,7 +322,7 @@ Label buttonPressedLabel
//{
// button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1;
//}
e.Cancel = true;
e.Handled = true;
};
dialog.Add (add);

Expand All @@ -340,7 +340,7 @@ Label buttonPressedLabel
button.Text += char.ConvertFromUtf32 (CODE_POINT);
}

e.Cancel = true;
e.Handled = true;
};
dialog.Add (addChar);

Expand Down
2 changes: 1 addition & 1 deletion Examples/UICatalog/Scenarios/Editors/DimEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private void DimEditor_Initialized (object? sender, EventArgs e)
{
// ignored
}
args.Cancel = true;
args.Handled = true;
};
Add (_valueEdit);

Expand Down
2 changes: 1 addition & 1 deletion Examples/UICatalog/Scenarios/Editors/PosEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private void PosEditor_Initialized (object? sender, EventArgs e)
// ignored
}

args.Cancel = true;
args.Handled = true;
};
Add (_valueEdit);

Expand Down
2 changes: 1 addition & 1 deletion Examples/UICatalog/Scenarios/FileDialogExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public override void Main ()
}
finally
{
e.Cancel = true;
e.Handled = true;
}
};
win.Add (btn);
Expand Down
4 changes: 2 additions & 2 deletions Examples/UICatalog/Scenarios/Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public override void Main ()

button.Accepting += (s, e) =>
{
// Anytime Accepting is handled, make sure to set e.Cancel to false.
e.Cancel = true;
// When Accepting is handled, set e.Handled to true to prevent further processing.
e.Handled = true;
MessageBox.ErrorQuery ("Error", "You pressed the button!", "_Ok");
};

Expand Down
4 changes: 2 additions & 2 deletions Examples/UICatalog/Scenarios/LineDrawing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static bool PromptForColor (string title, Color current, out Color newCol
btnOk.Accepting += (s, e) =>
{
accept = true;
e.Cancel = true;
e.Handled = true;
Application.RequestStop ();
};

Expand All @@ -167,7 +167,7 @@ public static bool PromptForColor (string title, Color current, out Color newCol

btnCancel.Accepting += (s, e) =>
{
e.Cancel = true;
e.Handled = true;
Application.RequestStop ();
};

Expand Down
Loading
Loading