mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Fixes #4023 - Changes CommandEventArgs to be based on HandledEventArgs instead of CancelEventArgs (#4054)
* touching publish.yml * CancelEventArgs->HandledEventArgs * Fixed Handled issues
This commit is contained in:
@@ -23,15 +23,15 @@ internal partial class LoginView : IRecipient<Message<LoginActions>>
|
||||
{
|
||||
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 (); };
|
||||
|
||||
@@ -78,8 +78,8 @@ public class ExampleWindow : Window
|
||||
{
|
||||
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
|
||||
|
||||
@@ -105,8 +105,8 @@ public class ExampleWindow : Window
|
||||
{
|
||||
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
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.SourceGenerators;
|
||||
using Terminal.Gui;
|
||||
|
||||
namespace ReactiveExample;
|
||||
|
||||
@@ -50,7 +51,7 @@ public partial class LoginViewModel : ReactiveObject
|
||||
|
||||
_isValidHelper = canLogin.ToProperty (this, x => x.IsValid);
|
||||
|
||||
Login = ReactiveCommand.CreateFromTask<HandledEventArgs>
|
||||
Login = ReactiveCommand.CreateFromTask<CommandEventArgs>
|
||||
(
|
||||
e => Task.Delay (TimeSpan.FromSeconds (1)),
|
||||
canLogin
|
||||
@@ -76,8 +77,8 @@ public partial class LoginViewModel : ReactiveObject
|
||||
}
|
||||
|
||||
[ReactiveCommand]
|
||||
public void Clear (HandledEventArgs args) { }
|
||||
public void Clear (CommandEventArgs args) { }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public ReactiveCommand<HandledEventArgs, Unit> Login { get; }
|
||||
public ReactiveCommand<CommandEventArgs, Unit> Login { get; }
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ public class ExampleWindow : Window
|
||||
{
|
||||
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
|
||||
|
||||
@@ -143,7 +143,7 @@ public class Adornments : Scenario
|
||||
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");
|
||||
|
||||
@@ -83,7 +83,7 @@ public class AllViewsTester : Scenario
|
||||
_classListView.Accepting += (sender, args) =>
|
||||
{
|
||||
_curView?.SetFocus ();
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
|
||||
_adornmentsEditor = new ()
|
||||
|
||||
@@ -486,7 +486,7 @@ public class Bars : Scenario
|
||||
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);
|
||||
}
|
||||
@@ -536,7 +536,7 @@ public class Bars : Scenario
|
||||
{
|
||||
button1.Visible = !button1.Visible;
|
||||
button1.Enabled = button1.Visible;
|
||||
e.Cancel = false;
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
bar.Add (new Label
|
||||
|
||||
@@ -49,16 +49,16 @@ public class Buttons : Scenario
|
||||
|
||||
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");
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class Buttons : Scenario
|
||||
{
|
||||
string btnText = button.Text;
|
||||
MessageBox.Query ("Message", $"Did you click {txt}?", "Yes", "No");
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Buttons : Scenario
|
||||
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" };
|
||||
@@ -122,7 +122,7 @@ public class Buttons : Scenario
|
||||
textChanger.Accepting += (s, e) =>
|
||||
{
|
||||
textChanger.Text += "!";
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
main.Add (
|
||||
@@ -133,7 +133,7 @@ public class Buttons : Scenario
|
||||
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
|
||||
{
|
||||
@@ -146,7 +146,7 @@ public class Buttons : Scenario
|
||||
removeButton.Accepting += (s, e) =>
|
||||
{
|
||||
removeButton.Visible = false;
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var computedFrame = new FrameView
|
||||
@@ -172,7 +172,7 @@ public class Buttons : Scenario
|
||||
moveBtn.Accepting += (s, e) =>
|
||||
{
|
||||
moveBtn.X = moveBtn.Frame.X + 5;
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
computedFrame.Add (moveBtn);
|
||||
|
||||
@@ -189,7 +189,7 @@ public class Buttons : Scenario
|
||||
sizeBtn.Accepting += (s, e) =>
|
||||
{
|
||||
sizeBtn.Width = sizeBtn.Frame.Width + 5;
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
computedFrame.Add (sizeBtn);
|
||||
|
||||
@@ -214,7 +214,7 @@ public class Buttons : Scenario
|
||||
moveBtnA.Frame.Width,
|
||||
moveBtnA.Frame.Height
|
||||
);
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
absoluteFrame.Add (moveBtnA);
|
||||
|
||||
@@ -232,7 +232,7 @@ public class Buttons : Scenario
|
||||
sizeBtnA.Frame.Width + 5,
|
||||
sizeBtnA.Frame.Height
|
||||
);
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
absoluteFrame.Add (sizeBtnA);
|
||||
|
||||
@@ -300,7 +300,7 @@ public class Buttons : Scenario
|
||||
moveHotKeyBtn.Accepting += (s, e) =>
|
||||
{
|
||||
moveHotKeyBtn.Text = MoveHotkey (moveHotKeyBtn.Text);
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
main.Add (moveHotKeyBtn);
|
||||
|
||||
@@ -317,7 +317,7 @@ public class Buttons : Scenario
|
||||
moveUnicodeHotKeyBtn.Accepting += (s, e) =>
|
||||
{
|
||||
moveUnicodeHotKeyBtn.Text = MoveHotkey (moveUnicodeHotKeyBtn.Text);
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
main.Add (moveUnicodeHotKeyBtn);
|
||||
|
||||
@@ -401,7 +401,7 @@ public class Buttons : Scenario
|
||||
noRepeatButton.Accepting += (s, e) =>
|
||||
{
|
||||
noRepeatButton.Title = $"Accept Cou_nt: {++noRepeatAcceptCount}";
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
main.Add (label, noRepeatButton);
|
||||
|
||||
@@ -423,7 +423,7 @@ public class Buttons : Scenario
|
||||
repeatButton.Accepting += (s, e) =>
|
||||
{
|
||||
repeatButton.Title = $"Accept Co_unt: {++acceptCount}";
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
var enableCB = new CheckBox
|
||||
|
||||
@@ -256,7 +256,7 @@ public class CharacterMap : Scenario
|
||||
_charMap.SetFocus ();
|
||||
|
||||
// Cancel the event to prevent ENTER from being handled elsewhere
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ public class Dialogs : Scenario
|
||||
);
|
||||
Application.Run (dlg);
|
||||
dlg.Dispose ();
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
app.Add (showDialogButton);
|
||||
@@ -258,7 +258,7 @@ public class Dialogs : Scenario
|
||||
button.Accepting += (s, e) =>
|
||||
{
|
||||
clicked = buttonId;
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
Application.RequestStop ();
|
||||
};
|
||||
buttons.Add (button);
|
||||
@@ -313,7 +313,7 @@ public class Dialogs : Scenario
|
||||
{
|
||||
clicked = buttonId;
|
||||
Application.RequestStop ();
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
buttons.Add (button);
|
||||
dialog.AddButton (button);
|
||||
@@ -322,7 +322,7 @@ public class Dialogs : Scenario
|
||||
//{
|
||||
// button.TabIndex = buttons [buttons.Count - 2].TabIndex + 1;
|
||||
//}
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
dialog.Add (add);
|
||||
|
||||
@@ -340,7 +340,7 @@ public class Dialogs : Scenario
|
||||
button.Text += char.ConvertFromUtf32 (CODE_POINT);
|
||||
}
|
||||
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
dialog.Add (addChar);
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DimEditor : EditorBase
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
Add (_valueEdit);
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public class PosEditor : EditorBase
|
||||
// ignored
|
||||
}
|
||||
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
Add (_valueEdit);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ public class FileDialogExamples : Scenario
|
||||
}
|
||||
finally
|
||||
{
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
win.Add (btn);
|
||||
|
||||
@@ -39,8 +39,8 @@ public sealed class Generic : Scenario
|
||||
|
||||
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");
|
||||
};
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ public class LineDrawing : Scenario
|
||||
btnOk.Accepting += (s, e) =>
|
||||
{
|
||||
accept = true;
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
Application.RequestStop ();
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ public class LineDrawing : Scenario
|
||||
|
||||
btnCancel.Accepting += (s, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
Application.RequestStop ();
|
||||
};
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class Menus : Scenario
|
||||
|
||||
menuHostView.CommandNotBound += (o, args) =>
|
||||
{
|
||||
if (o is not View sender || args.Cancel)
|
||||
if (o is not View sender || args.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class Menus : Scenario
|
||||
|
||||
menuHostView.Accepting += (o, args) =>
|
||||
{
|
||||
if (o is not View sender || args.Cancel)
|
||||
if (o is not View sender || args.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class Menus : Scenario
|
||||
|
||||
menuHostView.ContextMenu!.Accepted += (o, args) =>
|
||||
{
|
||||
if (o is not View sender || args.Cancel)
|
||||
if (o is not View sender || args.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -263,7 +263,7 @@ public class Menus : Scenario
|
||||
Logging.Debug ($"menuBar.Accepted: {args.Context.Source?.Title}");
|
||||
|
||||
// Set Cancel to true to stop propagation of Accepting to superview
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
|
||||
// Since overwrite uses a MenuItem.Command the menu item CB is the source of truth
|
||||
enableOverwriteStatusCb.CheckedState = ((CheckBox)mi.CommandView).CheckedState;
|
||||
@@ -308,7 +308,7 @@ public class Menus : Scenario
|
||||
Logging.Debug ($"menuBar.Accepted: {args.Context.Source?.Title}");
|
||||
|
||||
// Set Cancel to true to stop propagation of Accepting to superview
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
|
||||
// Since overwrite uses a MenuItem.Command the menu item CB is the source of truth
|
||||
editModeMenuItemCb.CheckedState = ((CheckBox)mi.CommandView).CheckedState;
|
||||
@@ -363,7 +363,7 @@ public class Menus : Scenario
|
||||
|
||||
openBtn.Accepting += (s, e) =>
|
||||
{
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
Logging.Trace ($"openBtn.Accepting - Sending F9. {e.Context?.Source?.Title}");
|
||||
NewKeyDownEvent (menuBar.Key);
|
||||
};
|
||||
|
||||
@@ -279,7 +279,7 @@ public class MessageBoxes : Scenario
|
||||
buttonPressedLabel.Text = "Invalid Options";
|
||||
}
|
||||
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
app.Add (showMessageBoxButton);
|
||||
|
||||
|
||||
@@ -426,7 +426,7 @@ public class Shortcuts : Scenario
|
||||
return;
|
||||
}
|
||||
bgColor.SelectedColor++;
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
|
||||
bgColor.ColorChanged += (o, args) =>
|
||||
@@ -467,7 +467,7 @@ public class Shortcuts : Scenario
|
||||
{
|
||||
shortcut.Selecting += (o, args) =>
|
||||
{
|
||||
if (args.Cancel)
|
||||
if (args.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -477,13 +477,13 @@ public class Shortcuts : Scenario
|
||||
|
||||
shortcut.CommandView.Selecting += (o, args) =>
|
||||
{
|
||||
if (args.Cancel)
|
||||
if (args.Handled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
eventSource.Add ($"{shortcut!.Id}.CommandView.Selecting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
||||
eventLog.MoveDown ();
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
|
||||
shortcut.Accepting += (o, args) =>
|
||||
@@ -491,7 +491,7 @@ public class Shortcuts : Scenario
|
||||
eventSource.Add ($"{shortcut!.Id}.Accepting: {shortcut!.CommandView.Text} {shortcut!.CommandView.GetType ().Name}");
|
||||
eventLog.MoveDown ();
|
||||
// We don't want this to exit the Scenario
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
|
||||
shortcut.CommandView.Accepting += (o, args) =>
|
||||
@@ -505,7 +505,7 @@ public class Shortcuts : Scenario
|
||||
|
||||
private void Button_Clicked (object? sender, CommandEventArgs e)
|
||||
{
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
View? view = sender as View;
|
||||
MessageBox.Query ("Hi", $"You clicked {view?.Text}", "_Ok");
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public sealed class SimpleDialog : Scenario
|
||||
button.Accepting += (s, e) =>
|
||||
{
|
||||
Application.Run (dialog);
|
||||
e.Cancel = true;
|
||||
e.Handled = true;
|
||||
};
|
||||
appWindow.Add (button);
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ public class Sliders : Scenario
|
||||
{
|
||||
eventSource.Add ($"Accept: {string.Join(",", slider.GetSetOptions ())}");
|
||||
eventLog.MoveDown ();
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
slider.OptionsChanged += (o, args) =>
|
||||
{
|
||||
|
||||
@@ -452,7 +452,7 @@ public class Text : Scenario
|
||||
|
||||
void WinOnAccept (object sender, CommandEventArgs e)
|
||||
{
|
||||
e.Cancel = true; // Don't let it close
|
||||
e.Handled = true; // Don't let it close
|
||||
|
||||
acceptView.Text = $"Accept was Invoked via {win.Focused.GetType().Name}";
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ public class UICatalogTop : Toplevel
|
||||
statusBarShortcut.Accepting += (sender, args) =>
|
||||
{
|
||||
statusBar.Visible = !_statusBar!.Visible;
|
||||
args.Cancel = true;
|
||||
args.Handled = true;
|
||||
};
|
||||
|
||||
_force16ColorsShortcutCb = new ()
|
||||
|
||||
Reference in New Issue
Block a user