From baf66ef704a7b3feed96c993a3d83275dd697c60 Mon Sep 17 00:00:00 2001 From: Tig Kindel Date: Sun, 7 Jan 2024 21:29:47 -0700 Subject: [PATCH] Removed Frame overrides --- .../Text/Autocomplete/PopupAutocomplete.cs | 11 -------- Terminal.Gui/View/Frame.cs | 2 +- Terminal.Gui/View/Layout/ViewLayout.cs | 3 +-- Terminal.Gui/Views/TextField.cs | 26 +++++++++---------- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs index d78767a46..a805b6cf3 100644 --- a/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs +++ b/Terminal.Gui/Text/Autocomplete/PopupAutocomplete.cs @@ -23,17 +23,6 @@ namespace Terminal.Gui { WantMousePositionReports = true; } - public override Rect Frame { - get => base.Frame; - set { - base.Frame = value; - X = value.X; - Y = value.Y; - Width = value.Width; - Height = value.Height; - } - } - public override void OnDrawContent (Rect contentArea) { if (autocomplete.LastPopupPos == null) { diff --git a/Terminal.Gui/View/Frame.cs b/Terminal.Gui/View/Frame.cs index 95220f96e..484ce3cd1 100644 --- a/Terminal.Gui/View/Frame.cs +++ b/Terminal.Gui/View/Frame.cs @@ -58,7 +58,7 @@ namespace Terminal.Gui { /// public override Rect FrameToScreen () { - // Frames are *Children* of a View, not SubViews. Thus View.FramToScreen will not work. + // Frames are *Children* of a View, not SubViews. Thus View.FrameToScreen will not work. // To get the screen-relative coordinates of a Frame, we need to know who // the Parent is var ret = Parent?.Frame ?? Frame; diff --git a/Terminal.Gui/View/Layout/ViewLayout.cs b/Terminal.Gui/View/Layout/ViewLayout.cs index 6b0c79c47..5acefd6c7 100644 --- a/Terminal.Gui/View/Layout/ViewLayout.cs +++ b/Terminal.Gui/View/Layout/ViewLayout.cs @@ -52,8 +52,7 @@ public partial class View { /// /// /// Altering the Frame will eventually (when the view is next drawn) cause the - /// - /// and methods to be called. + /// and methods to be called. /// /// public virtual Rect Frame { diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs index acaf46fdb..024942f11 100644 --- a/Terminal.Gui/Views/TextField.cs +++ b/Terminal.Gui/Views/TextField.cs @@ -110,6 +110,8 @@ namespace Terminal.Gui { Initialized += TextField_Initialized; + LayoutComplete += TextField_LayoutComplete; + // Things this view knows how to do AddCommand (Command.DeleteCharRight, () => { DeleteCharRight (); return true; }); AddCommand (Command.DeleteCharLeft, () => { DeleteCharLeft (false); return true; }); @@ -219,6 +221,16 @@ namespace Terminal.Gui { KeyBindings.Add (ContextMenu.Key.KeyCode, KeyBindingScope.HotKey, Command.ShowContextMenu); } + private void TextField_LayoutComplete (object sender, LayoutEventArgs e) + { + // Don't let height > 1 + if (Frame.Height > 1) { + Height = 1; + } + Adjust (); + } + + private MenuBarItem BuildContextMenuBarItem () { return new MenuBarItem (new MenuItem [] { @@ -280,20 +292,6 @@ namespace Terminal.Gui { /// public IAutocomplete Autocomplete { get; set; } = new TextFieldAutocomplete (); - /// - public override Rect Frame { - get => base.Frame; - set { - if (value.Height > 1) { - base.Frame = new Rect (value.X, value.Y, value.Width, 1); - Height = 1; - } else { - base.Frame = value; - } - Adjust (); - } - } - /// /// Sets or gets the text held by the view. ///