diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs
index 50fbfb507..bcf9ec022 100644
--- a/Terminal.Gui/View/View.cs
+++ b/Terminal.Gui/View/View.cs
@@ -67,7 +67,8 @@ namespace Terminal.Gui;
/// a View can be accessed with the property.
///
///
-/// To flag a region of the View's to be redrawn call
+/// To flag a region of the View's to be redrawn call
+///
/// .
/// To flag the entire view for redraw call .
///
@@ -106,6 +107,61 @@ namespace Terminal.Gui;
public partial class View : Responder, ISupportInitializeNotification
{
+ ///
+ /// Cancelable event fired when the command is invoked. Set
+ ///
+ /// to cancel the event.
+ ///
+ public event EventHandler Accept;
+
+ /// Gets or sets arbitrary data for the view.
+ /// This property is not used internally.
+ public object Data { get; set; }
+
+ /// Gets or sets an identifier for the view;
+ /// The identifier.
+ /// The id should be unique across all Views that share a SuperView.
+ public string Id { get; set; } = "";
+
+ /// Pretty prints the View
+ ///
+ public override string ToString () { return $"{GetType ().Name}({Id}){Frame}"; }
+
+ ///
+ protected override void Dispose (bool disposing)
+ {
+ LineCanvas.Dispose ();
+
+ DisposeKeyboard ();
+ DisposeAdornments ();
+
+ for (int i = InternalSubviews.Count - 1; i >= 0; i--)
+ {
+ View subview = InternalSubviews [i];
+ Remove (subview);
+ subview.Dispose ();
+ }
+
+ base.Dispose (disposing);
+ Debug.Assert (InternalSubviews.Count == 0);
+ }
+
+ ///
+ /// Called when the command is invoked. Fires the
+ /// event.
+ ///
+ ///
+ /// If the event was canceled. If the event was fired but not canceled.
+ /// If no event was fired.
+ ///
+ protected bool? OnAccept ()
+ {
+ var args = new CancelEventArgs ();
+ Accept?.Invoke (this, args);
+
+ return Accept is null ? null : args.Cancel;
+ }
+
#region Constructors and Initialization
///
@@ -125,6 +181,7 @@ public partial class View : Responder, ISupportInitializeNotification
{
SetupAdornments ();
SetupKeyboard ();
+
//SetupMouse ();
SetupText ();
@@ -230,40 +287,10 @@ public partial class View : Responder, ISupportInitializeNotification
}
Initialized?.Invoke (this, EventArgs.Empty);
-
}
#endregion Constructors and Initialization
- /// Gets or sets an identifier for the view;
- /// The identifier.
- /// The id should be unique across all Views that share a SuperView.
- public string Id { get; set; } = "";
-
- /// Gets or sets arbitrary data for the view.
- /// This property is not used internally.
- public object Data { get; set; }
-
- ///
- /// Cancelable event fired when the command is invoked. Set
- ///
- /// to cancel the event.
- ///
- public event EventHandler Accept;
-
- ///
- /// Called when the command is invoked. Fires the
- /// event.
- ///
- /// If the event was canceled.
- protected bool? OnAccept ()
- {
- var args = new CancelEventArgs ();
- Accept?.Invoke (this, args);
-
- return Accept is null ? null : args.Cancel;
- }
-
#region Visibility
private bool _enabled = true;
@@ -318,6 +345,7 @@ public partial class View : Responder, ISupportInitializeNotification
public virtual void OnEnabledChanged () { EnabledChanged?.Invoke (this, EventArgs.Empty); }
private bool _visible = true;
+
/// Gets or sets a value indicating whether this and all its child controls are displayed.
public virtual bool Visible
{
@@ -349,7 +377,6 @@ public partial class View : Responder, ISupportInitializeNotification
}
}
-
/// Method invoked when the property from a view is changed.
public virtual void OnVisibleChanged () { VisibleChanged?.Invoke (this, EventArgs.Empty); }
@@ -494,27 +521,4 @@ public partial class View : Responder, ISupportInitializeNotification
public event EventHandler> TitleChanging;
#endregion
-
- /// Pretty prints the View
- ///
- public override string ToString () { return $"{GetType ().Name}({Id}){Frame}"; }
-
- ///
- protected override void Dispose (bool disposing)
- {
- LineCanvas.Dispose ();
-
- DisposeKeyboard ();
- DisposeAdornments ();
-
- for (int i = InternalSubviews.Count - 1; i >= 0; i--)
- {
- View subview = InternalSubviews [i];
- Remove (subview);
- subview.Dispose ();
- }
-
- base.Dispose (disposing);
- Debug.Assert (InternalSubviews.Count == 0);
- }
}
diff --git a/Terminal.Gui/View/ViewKeyboard.cs b/Terminal.Gui/View/ViewKeyboard.cs
index 508bbd9da..127c3fac9 100644
--- a/Terminal.Gui/View/ViewKeyboard.cs
+++ b/Terminal.Gui/View/ViewKeyboard.cs
@@ -415,6 +415,8 @@ public partial class View
return true;
}
+ // TODO: NewKeyDownEvent returns bool. It should be bool? so state of InvokeCommand can be reflected up stack
+
bool? handled = OnInvokingKeyBindings (keyEvent, KeyBindingScope.HotKey | KeyBindingScope.Focused);
if (handled is { } && (bool)handled)
diff --git a/Terminal.Gui/Views/RadioGroup.cs b/Terminal.Gui/Views/RadioGroup.cs
index c87ae9964..9d60dc950 100644
--- a/Terminal.Gui/Views/RadioGroup.cs
+++ b/Terminal.Gui/Views/RadioGroup.cs
@@ -84,7 +84,7 @@ public class RadioGroup : View
{
SelectedItem = _cursor;
- return !OnAccept ();
+ return OnAccept () != false;
}
);
@@ -97,7 +97,7 @@ public class RadioGroup : View
{
SelectedItem = (int)ctx.KeyBinding?.Context!;
- return !OnAccept();
+ return OnAccept () != false;
}
return true;