diff --git a/Terminal.Gui/Application.cs b/Terminal.Gui/Application.cs
index 4dd46e8332..bc42520541 100644
--- a/Terminal.Gui/Application.cs
+++ b/Terminal.Gui/Application.cs
@@ -1208,9 +1208,9 @@ static void OnUnGrabbedMouse (View view)
static void ProcessMouseEvent (MouseEvent me)
{
- bool OutsideFrame (Point p, Rect r)
+ bool OutsideBounds (Point p, Rect r)
{
- return p.X < 0 || p.X > r.Width - 1 || p.Y < 0 || p.Y > r.Height - 1;
+ return p.X < 0 || p.X > r.Right || p.Y < 0 || p.Y > r.Bottom;
}
if (IsMouseDisabled) {
@@ -1243,7 +1243,7 @@ bool OutsideFrame (Point p, Rect r)
OfY = me.Y - newxy.Y,
View = view
};
- if (OutsideFrame (new Point (nme.X, nme.Y), _mouseGrabView.Frame)) {
+ if (OutsideBounds (new Point (nme.X, nme.Y), _mouseGrabView.Bounds)) {
_lastMouseOwnerView?.OnMouseLeave (me);
}
//System.Diagnostics.Debug.WriteLine ($"{nme.Flags};{nme.X};{nme.Y};{mouseGrabView}");
diff --git a/Terminal.Gui/View/View.cs b/Terminal.Gui/View/View.cs
index 7e662a72fe..c9fea00d5f 100644
--- a/Terminal.Gui/View/View.cs
+++ b/Terminal.Gui/View/View.cs
@@ -434,7 +434,7 @@ public override bool Enabled {
}
}
}
-
+
///
/// Event fired when the value is being changed.
///
@@ -481,7 +481,7 @@ bool CanBeVisible (View view)
return true;
}
-
+
///
/// Pretty prints the View
///
diff --git a/Terminal.Gui/Views/ContextMenu.cs b/Terminal.Gui/Views/ContextMenu.cs
index 13f0b66f2b..2c94e50b86 100644
--- a/Terminal.Gui/Views/ContextMenu.cs
+++ b/Terminal.Gui/Views/ContextMenu.cs
@@ -33,7 +33,7 @@ public sealed class ContextMenu : IDisposable {
public ContextMenu () : this (0, 0, new MenuBarItem ()) { }
///
- /// Initializes a context menu, with a specifiying the parent/hose of the menu.
+ /// Initializes a context menu, with a specifying the parent/host of the menu.
///
/// The host view.
/// The menu items for the context menu.
@@ -79,7 +79,6 @@ public void Dispose ()
}
if (container != null) {
container.Closing -= Container_Closing;
- container.TerminalResized -= Container_Resized;
}
}
@@ -91,13 +90,12 @@ public void Show ()
if (menuBar != null) {
Hide ();
}
- container = Application.Top;
+ container = Application.Current;
container.Closing += Container_Closing;
- container.TerminalResized += Container_Resized;
- var frame = container.Frame;
+ var frame = new Rect (0, 0, View.Driver.Cols, View.Driver.Rows);
var position = Position;
if (Host != null) {
- Host.ViewToScreen (container.Frame.X, container.Frame.Y, out int x, out int y);
+ Host.ViewToScreen (frame.X, frame.Y, out int x, out int y);
var pos = new Point (x, y);
pos.Y += Host.Frame.Height - 1;
if (position != pos) {
@@ -119,7 +117,7 @@ public void Show ()
if (Host == null) {
position.Y = frame.Bottom - rect.Height - 1;
} else {
- Host.ViewToScreen (container.Frame.X, container.Frame.Y, out int x, out int y);
+ Host.ViewToScreen (frame.X, frame.Y, out int x, out int y);
var pos = new Point (x, y);
position.Y = pos.Y - rect.Height - 1;
}
@@ -145,13 +143,6 @@ public void Show ()
menuBar.OpenMenu ();
}
- private void Container_Resized (object sender, SizeChangedEventArgs e)
- {
- if (IsShow) {
- Show ();
- }
- }
-
private void Container_Closing (object sender, ToplevelClosingEventArgs obj)
{
Hide ();
diff --git a/Terminal.Gui/Views/Menu.cs b/Terminal.Gui/Views/Menu.cs
index 0014235254..b0cc4101d4 100644
--- a/Terminal.Gui/Views/Menu.cs
+++ b/Terminal.Gui/Views/Menu.cs
@@ -202,7 +202,7 @@ public MenuItemCheckStyle CheckType {
/// Gets the parent for this .
///
/// The parent.
- public MenuItem Parent { get; internal set; }
+ public MenuItem Parent { get; set; }
///
/// Gets if this is from a sub-menu.
@@ -443,7 +443,7 @@ internal static Rect MakeFrame (int x, int y, MenuItem [] items, Menu parent = n
}
int minX = x;
int minY = y;
- var borderOffset = border != LineStyle.None ? 2 : 0; // This 2 is frame border?
+ var borderOffset = 2; // This 2 is for the space around
int maxW = (items.Max (z => z?.Width) ?? 0) + borderOffset;
int maxH = items.Length + borderOffset;
if (parent != null && x + maxW > Driver.Cols) {
@@ -482,6 +482,7 @@ public Menu (MenuBar host, int x, int y, MenuBarItem barItems, Menu parent = nul
if (Application.Current != null) {
Application.Current.DrawContentComplete += Current_DrawContentComplete;
+ Application.Current.TerminalResized += Current_TerminalResized;
}
Application.RootMouseEvent += Application_RootMouseEvent;
@@ -510,10 +511,40 @@ public Menu (MenuBar host, int x, int y, MenuBarItem barItems, Menu parent = nul
AddKeyBinding (Key.Enter, Command.Accept);
}
+ private void Current_TerminalResized (object sender, SizeChangedEventArgs e)
+ {
+ if (host.IsMenuOpen) {
+ host.CloseAllMenus ();
+ }
+ }
+
+ ///
+ public override void OnVisibleChanged ()
+ {
+ base.OnVisibleChanged ();
+ if (Visible) {
+ Application.RootMouseEvent += Application_RootMouseEvent;
+ } else {
+ Application.RootMouseEvent -= Application_RootMouseEvent;
+ }
+ }
+
private void Application_RootMouseEvent (MouseEvent me)
{
- var view = View.FindDeepestView (this, me.X, me.Y, out int rx, out int ry);
+ if (me.View is MenuBar) {
+ return;
+ }
+ var locationOffset = host.GetScreenOffsetFromCurrent ();
+ if (SuperView != null && SuperView != Application.Current) {
+ locationOffset.X += SuperView.Border.Thickness.Left;
+ locationOffset.Y += SuperView.Border.Thickness.Top;
+ }
+ var view = View.FindDeepestView (this, me.X + locationOffset.X, me.Y + locationOffset.Y, out int rx, out int ry);
if (view == this) {
+ if (!Visible) {
+ throw new InvalidOperationException ("This shouldn't running on a invisible menu!");
+ }
+
var nme = new MouseEvent () {
X = rx,
Y = ry,
@@ -540,8 +571,8 @@ public override void OnDrawContent (Rect contentArea)
if (barItems.Children == null) {
return;
}
- var savedClip = Application.Driver.Clip;
- Application.Driver.Clip = Application.Top.Frame;
+ var savedClip = Driver.Clip;
+ Driver.Clip = new Rect (0, 0, Driver.Cols, Driver.Rows);
Driver.SetAttribute (GetNormalColor ());
@@ -549,8 +580,12 @@ public override void OnDrawContent (Rect contentArea)
OnRenderLineCanvas ();
for (int i = Bounds.Y; i < barItems.Children.Length; i++) {
- if (i < 0)
+ if (i < 0) {
continue;
+ }
+ if (ViewToScreen (Bounds).Y + i >= Driver.Rows) {
+ break;
+ }
var item = barItems.Children [i];
Driver.SetAttribute (item == null ? GetNormalColor ()
: i == current ? ColorScheme.Focus : GetNormalColor ());
@@ -563,8 +598,12 @@ public override void OnDrawContent (Rect contentArea)
Driver.SetAttribute (DetermineColorSchemeFor (item, i));
for (int p = Bounds.X; p < Frame.Width - 2; p++) { // This - 2 is for the border
- if (p < 0)
+ if (p < 0) {
continue;
+ }
+ if (ViewToScreen (Bounds).X + p >= Driver.Cols) {
+ break;
+ }
if (item == null)
Driver.AddRune (Driver.HLine);
else if (i == 0 && p == 0 && host.UseSubMenusSingleFrame && item.Parent.Parent != null)
@@ -605,9 +644,9 @@ public override void OnDrawContent (Rect contentArea)
textToDraw = item.Title;
}
- ViewToScreen (0, i, out int vtsCol, out _, false);
+ ViewToScreen (0, i, out int vtsCol, out int vtsRow, false);
if (vtsCol < Driver.Cols) {
- Move (1, i);
+ Driver.Move (vtsCol + 1, vtsRow);
if (!item.IsEnabled ()) {
DrawHotString (textToDraw, ColorScheme.Disabled, ColorScheme.Disabled);
} else if (i == 0 && host.UseSubMenusSingleFrame && item.Parent.Parent != null) {
@@ -630,15 +669,14 @@ public override void OnDrawContent (Rect contentArea)
// The help string
var l = item.ShortcutTag.ConsoleWidth == 0 ? item.Help.ConsoleWidth : item.Help.ConsoleWidth + item.ShortcutTag.ConsoleWidth + 2;
var col = Frame.Width - l - 3;
- ViewToScreen (col, i, out vtsCol, out _, false);
+ ViewToScreen (col, i, out vtsCol, out vtsRow, false);
if (vtsCol < Driver.Cols) {
- Move (col, i);
+ Driver.Move (vtsCol, vtsRow);
Driver.AddStr (item.Help);
// The shortcut tag string
if (!item.ShortcutTag.IsEmpty) {
- l = item.ShortcutTag.ConsoleWidth;
- Move (Frame.Width - l - 3, i);
+ Driver.Move (vtsCol + l - item.ShortcutTag.ConsoleWidth, vtsRow);
Driver.AddStr (item.ShortcutTag);
}
}
@@ -651,7 +689,9 @@ public override void OnDrawContent (Rect contentArea)
private void Current_DrawContentComplete (object sender, DrawEventArgs e)
{
- OnDrawContent (Bounds);
+ if (Visible) {
+ OnDrawContent (Bounds);
+ }
}
public override void PositionCursor ()
@@ -858,12 +898,11 @@ public override bool MouseEvent (MouseEvent me)
}
host.handled = false;
bool disabled;
- var meYOffset = BorderStyle != LineStyle.None ? 1 : 0;
+ var meY = me.Y - (Border == null ? 0 : Border.Thickness.Top);
if (me.Flags == MouseFlags.Button1Clicked) {
disabled = false;
- if (me.Y < meYOffset)
+ if (meY < 0)
return true;
- var meY = me.Y - meYOffset;
if (meY >= barItems.Children.Length)
return true;
var item = barItems.Children [meY];
@@ -878,14 +917,14 @@ public override bool MouseEvent (MouseEvent me)
me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition)) {
disabled = false;
- if (me.Y < meYOffset || me.Y - meYOffset >= barItems.Children.Length) {
+ if (meY < 0 || meY >= barItems.Children.Length) {
return true;
}
- var item = barItems.Children [me.Y - meYOffset];
+ var item = barItems.Children [meY];
if (item == null) return true;
if (item == null || !item.IsEnabled ()) disabled = true;
if (item != null && !disabled)
- current = me.Y - meYOffset;
+ current = meY;
if (host.UseSubMenusSingleFrame || !CheckSubMenu ()) {
SetNeedsDisplay ();
SetParentSetNeedsDisplay ();
@@ -950,6 +989,7 @@ protected override void Dispose (bool disposing)
{
if (Application.Current != null) {
Application.Current.DrawContentComplete -= Current_DrawContentComplete;
+ Application.Current.TerminalResized -= Current_TerminalResized;
}
Application.RootMouseEvent -= Application_RootMouseEvent;
base.Dispose (disposing);
@@ -1284,7 +1324,7 @@ internal Menu openCurrentMenu {
set {
if (ocm != value) {
ocm = value;
- if (ocm.current > -1) {
+ if (ocm != null && ocm.current > -1) {
OnMenuOpened ();
}
}
@@ -1381,7 +1421,7 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem subMenu = null)
if (openSubMenu != null && !CloseMenu (false, true))
return;
if (openMenu != null) {
- Application.Top.Remove (openMenu);
+ Application.Current.Remove (openMenu);
openMenu.Dispose ();
openMenu = null;
}
@@ -1390,18 +1430,21 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem subMenu = null)
// text belonging to the menu
for (int i = 0; i < index; i++)
pos += Menus [i].TitleLength + (Menus [i].Help.ConsoleWidth > 0 ? Menus [i].Help.ConsoleWidth + 2 : 0) + leftPadding + rightPadding;
- var superView = SuperView == null ? Application.Top : SuperView;
- Point locationOffset;
- if (superView.BorderStyle != LineStyle.None) {
- locationOffset = new Point (superView.Frame.X + 1, superView.Frame.Y + 1);
- } else {
- locationOffset = new Point (superView.Frame.X, superView.Frame.Y);
+
+ var locationOffset = Point.Empty;
+ // if SuperView is null then it's from a ContextMenu
+ if (SuperView == null) {
+ locationOffset = GetScreenOffset ();
+ }
+ if (SuperView != null && SuperView != Application.Current) {
+ locationOffset.X += SuperView.Border.Thickness.Left;
+ locationOffset.Y += SuperView.Border.Thickness.Top;
}
openMenu = new Menu (this, Frame.X + pos + locationOffset.X, Frame.Y + 1 + locationOffset.Y, Menus [index], null, MenusBorderStyle);
openCurrentMenu = openMenu;
openCurrentMenu.previousSubFocused = openMenu;
- Application.Top.Add (openMenu);
+ Application.Current.Add (openMenu);
openMenu.SetFocus ();
break;
default:
@@ -1417,21 +1460,21 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem subMenu = null)
openCurrentMenu = new Menu (this, last.Frame.Left + last.Frame.Width + locationOffset.X, last.Frame.Top + locationOffset.Y + last.current, subMenu, last, MenusBorderStyle);
} else {
var first = openSubMenu.Count > 0 ? openSubMenu.First () : openMenu;
+ // 2 is for the parent and the separator
var mbi = new MenuItem [2 + subMenu.Children.Length];
mbi [0] = new MenuItem () { Title = subMenu.Title, Parent = subMenu };
mbi [1] = null;
for (int j = 0; j < subMenu.Children.Length; j++) {
mbi [j + 2] = subMenu.Children [j];
}
- var newSubMenu = new MenuBarItem (mbi);
- ViewToScreen (first.Frame.Left, first.Frame.Top, out int rx, out int ry);
- openCurrentMenu = new Menu (this, rx, ry, newSubMenu, null, MenusBorderStyle);
+ var newSubMenu = new MenuBarItem (mbi) { Parent = subMenu };
+ openCurrentMenu = new Menu (this, first.Frame.Left, first.Frame.Top, newSubMenu, null, MenusBorderStyle);
last.Visible = false;
Application.GrabMouse (openCurrentMenu);
}
openCurrentMenu.previousSubFocused = last.previousSubFocused;
openSubMenu.Add (openCurrentMenu);
- Application.Top.Add (openCurrentMenu);
+ Application.Current.Add (openCurrentMenu);
}
selectedSub = openSubMenu.Count - 1;
if (selectedSub > -1 && SelectEnabledItem (openCurrentMenu.barItems.Children, openCurrentMenu.current, out openCurrentMenu.current)) {
@@ -1562,7 +1605,7 @@ internal bool CloseMenu (bool reopen = false, bool isSubMenu = false, bool ignor
switch (isSubMenu) {
case false:
if (openMenu != null) {
- Application.Top.Remove (openMenu);
+ Application.Current.Remove (openMenu);
}
SetNeedsDisplay ();
if (previousFocused != null && previousFocused is Menu && openMenu != null && previousFocused.ToString () != openCurrentMenu.ToString ())
@@ -1578,6 +1621,14 @@ internal bool CloseMenu (bool reopen = false, bool isSubMenu = false, bool ignor
if (!reopen) {
selected = -1;
}
+ if (openSubMenu != null) {
+ openSubMenu = null;
+ }
+ if (openCurrentMenu != null) {
+ Application.Current.Remove (openCurrentMenu);
+ openCurrentMenu.Dispose ();
+ openCurrentMenu = null;
+ }
LastFocused.SetFocus ();
} else if (openSubMenu == null || openSubMenu.Count == 0) {
CloseAllMenus ();
@@ -1621,7 +1672,7 @@ void RemoveSubMenu (int index, bool ignoreUseSubMenusSingleFrame = false)
openCurrentMenu.SetFocus ();
if (openSubMenu != null) {
menu = openSubMenu [i];
- Application.Top.Remove (menu);
+ Application.Current.Remove (menu);
openSubMenu.Remove (menu);
menu.Dispose ();
}
@@ -1637,7 +1688,7 @@ internal void RemoveAllOpensSubMenus ()
{
if (openSubMenu != null) {
foreach (var item in openSubMenu) {
- Application.Top.Remove (item);
+ Application.Current.Remove (item);
item.Dispose ();
}
}
@@ -1646,7 +1697,7 @@ internal void RemoveAllOpensSubMenus ()
internal void CloseAllMenus ()
{
if (!isMenuOpening && !isMenuClosing) {
- if (openSubMenu != null && !CloseMenu (false, true))
+ if (openSubMenu != null && !CloseMenu (false, true, true))
return;
if (!CloseMenu (false))
return;
@@ -1923,7 +1974,12 @@ public override bool MouseEvent (MouseEvent me)
(me.Flags == MouseFlags.ReportMousePosition && selected > -1) ||
(me.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition) && selected > -1)) {
int pos = xOrigin;
- int cx = me.X;
+ Point locationOffset = default;
+ if (SuperView != null) {
+ locationOffset.X += SuperView.Border.Thickness.Left;
+ locationOffset.Y += SuperView.Border.Thickness.Top;
+ }
+ int cx = me.X - locationOffset.X;
for (int i = 0; i < Menus.Length; i++) {
if (cx >= pos && cx < pos + leftPadding + Menus [i].TitleLength + Menus [i].Help.ConsoleWidth + rightPadding) {
if (me.Flags == MouseFlags.Button1Clicked) {
@@ -1949,11 +2005,19 @@ public override bool MouseEvent (MouseEvent me)
}
Activate (i);
}
- } else {
- if (IsMenuOpen)
+ } else if (IsMenuOpen) {
+ if (!UseSubMenusSingleFrame || (UseSubMenusSingleFrame && openCurrentMenu != null
+ && openCurrentMenu.barItems.Parent != null && openCurrentMenu.barItems.Parent.Parent != Menus [i])) {
+
Activate (i);
+ }
}
return true;
+ } else if (i == Menus.Length - 1 && me.Flags == MouseFlags.Button1Clicked) {
+ if (IsMenuOpen && !Menus [i].IsTopLevel) {
+ CloseAllMenus ();
+ return true;
+ }
}
pos += leftPadding + Menus [i].TitleLength + rightPadding;
}
@@ -2065,5 +2129,31 @@ public override bool OnEnter (View view)
return base.OnEnter (view);
}
+
+ ///
+ /// Gets the superview location offset relative to the location.
+ ///
+ /// The location offset.
+ internal Point GetScreenOffset ()
+ {
+ var superViewFrame = SuperView == null ? new Rect (0, 0, Driver.Cols, Driver.Rows) : SuperView.Frame;
+ var sv = SuperView == null ? Application.Current : SuperView;
+ var boundsOffset = sv.GetBoundsOffset ();
+ return new Point (superViewFrame.X - sv.Frame.X - boundsOffset.X,
+ superViewFrame.Y - sv.Frame.Y - boundsOffset.Y);
+ }
+
+ ///
+ /// Gets the location offset relative to the location.
+ ///
+ /// The location offset.
+ internal Point GetScreenOffsetFromCurrent ()
+ {
+ var screen = new Rect (0, 0, Driver.Cols, Driver.Rows);
+ var currentFrame = Application.Current.Frame;
+ var boundsOffset = Application.Top.GetBoundsOffset ();
+ return new Point (screen.X - currentFrame.X - boundsOffset.X
+ , screen.Y - currentFrame.Y - boundsOffset.Y);
+ }
}
}
diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs
index a689bf192d..f4c8e3b6aa 100644
--- a/Terminal.Gui/Views/TextField.cs
+++ b/Terminal.Gui/Views/TextField.cs
@@ -293,7 +293,12 @@ public override bool OnLeave (View view)
public override Rect Frame {
get => base.Frame;
set {
- base.Frame = value;
+ if (value.Height > 1) {
+ base.Frame = new Rect(value.X, value.Y, value.Width, 1);
+ Height = 1;
+ } else {
+ base.Frame = value;
+ }
Adjust ();
}
}
diff --git a/UICatalog/Scenarios/DynamicMenuBar.cs b/UICatalog/Scenarios/DynamicMenuBar.cs
index 18ce15d63b..a671e6494e 100644
--- a/UICatalog/Scenarios/DynamicMenuBar.cs
+++ b/UICatalog/Scenarios/DynamicMenuBar.cs
@@ -208,7 +208,7 @@ public DynamicMenuBarSample () : base ()
};
Add (_frmMenuDetails);
- _btnMenuBarUp.Clicked += (s,e) => {
+ _btnMenuBarUp.Clicked += (s, e) => {
var i = _currentSelectedMenuBar;
var menuItem = _menuBar != null && _menuBar.Menus.Length > 0 ? _menuBar.Menus [i] : null;
if (menuItem != null) {
@@ -222,7 +222,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnMenuBarDown.Clicked += (s,e) => {
+ _btnMenuBarDown.Clicked += (s, e) => {
var i = _currentSelectedMenuBar;
var menuItem = _menuBar != null && _menuBar.Menus.Length > 0 ? _menuBar.Menus [i] : null;
if (menuItem != null) {
@@ -236,7 +236,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnUp.Clicked += (s,e) => {
+ _btnUp.Clicked += (s, e) => {
var i = _lstMenus.SelectedItem;
var menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null;
if (menuItem != null) {
@@ -251,7 +251,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnDown.Clicked += (s,e) => {
+ _btnDown.Clicked += (s, e) => {
var i = _lstMenus.SelectedItem;
var menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [i].MenuItem : null;
if (menuItem != null) {
@@ -266,7 +266,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnPreviowsParent.Clicked += (s,e) => {
+ _btnPreviowsParent.Clicked += (s, e) => {
if (_currentMenuBarItem != null && _currentMenuBarItem.Parent != null) {
var mi = _currentMenuBarItem;
_currentMenuBarItem = _currentMenuBarItem.Parent as MenuBarItem;
@@ -295,16 +295,16 @@ public DynamicMenuBarSample () : base ()
X = Pos.Right (_btnOk) + 3,
Y = Pos.Top (_btnOk),
};
- _btnCancel.Clicked += (s,e) => {
+ _btnCancel.Clicked += (s, e) => {
SetFrameDetails (_currentEditMenuBarItem);
};
Add (_btnCancel);
- _lstMenus.SelectedItemChanged += (s,e) => {
+ _lstMenus.SelectedItemChanged += (s, e) => {
SetFrameDetails ();
};
- _btnOk.Clicked += (s,e) => {
+ _btnOk.Clicked += (s, e) => {
if (ustring.IsNullOrEmpty (_frmMenuDetails._txtTitle.Text) && _currentEditMenuBarItem != null) {
MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
} else if (_currentEditMenuBarItem != null) {
@@ -320,7 +320,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnAdd.Clicked += (s,e) => {
+ _btnAdd.Clicked += (s, e) => {
if (MenuBar == null) {
MessageBox.ErrorQuery ("Menu Bar Error", "Must add a MenuBar first!", "Ok");
_btnAddMenuBar.SetFocus ();
@@ -357,7 +357,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnRemove.Clicked += (s,e) => {
+ _btnRemove.Clicked += (s, e) => {
var menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem : null;
if (menuItem != null) {
var childrens = ((MenuBarItem)_currentMenuBarItem).Children;
@@ -389,7 +389,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _lstMenus.OpenSelectedItem += (s,e) => {
+ _lstMenus.OpenSelectedItem += (s, e) => {
_currentMenuBarItem = DataContext.Menus [e.Item].MenuItem;
if (!(_currentMenuBarItem is MenuBarItem)) {
MessageBox.ErrorQuery ("Menu Open Error", "Must allows sub menus first!", "Ok");
@@ -403,18 +403,18 @@ public DynamicMenuBarSample () : base ()
};
_lstMenus.Enter += (s, e) => {
- var menuBarItem = DataContext.Menus.Count > 0 ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem : null;
+ var menuBarItem = _lstMenus.SelectedItem > -1 && DataContext.Menus.Count > 0 ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem : null;
SetFrameDetails (menuBarItem);
};
- _btnNext.Clicked += (s,e) => {
+ _btnNext.Clicked += (s, e) => {
if (_menuBar != null && _currentSelectedMenuBar + 1 < _menuBar.Menus.Length) {
_currentSelectedMenuBar++;
}
SelectCurrentMenuBarItem ();
};
- _btnPrevious.Clicked += (s,e) => {
+ _btnPrevious.Clicked += (s, e) => {
if (_currentSelectedMenuBar - 1 > -1) {
_currentSelectedMenuBar--;
}
@@ -428,7 +428,7 @@ public DynamicMenuBarSample () : base ()
}
};
- _btnAddMenuBar.Clicked += (s,e) => {
+ _btnAddMenuBar.Clicked += (s, e) => {
var frameDetails = new DynamicMenuBarDetails (null, false);
var item = frameDetails.EnterMenuItem ();
if (item == null) {
@@ -455,7 +455,7 @@ public DynamicMenuBarSample () : base ()
_menuBar.SetNeedsDisplay ();
};
- _btnRemoveMenuBar.Clicked += (s,e) => {
+ _btnRemoveMenuBar.Clicked += (s, e) => {
if (_menuBar == null || _menuBar.Menus.Length == 0) {
return;
}
@@ -505,7 +505,7 @@ void SetFrameDetails (MenuItem menuBarItem = null)
MenuItem menuItem;
if (menuBarItem == null) {
- menuItem = DataContext.Menus.Count > 0 ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem : null;
+ menuItem = _lstMenus.SelectedItem > -1 && DataContext.Menus.Count > 0 ? DataContext.Menus [_lstMenus.SelectedItem].MenuItem : null;
} else {
menuItem = menuBarItem;
}
@@ -778,7 +778,7 @@ bool CheckShortcut (Key k, bool pre)
X = Pos.X (_lblShortcut),
Y = Pos.Bottom (_txtShortcut) + 1
};
- _btnShortcut.Clicked += (s,e) => {
+ _btnShortcut.Clicked += (s, e) => {
_txtShortcut.Text = "";
};
Add (_btnShortcut);
@@ -829,7 +829,7 @@ bool CheckShortcut (Key k, bool pre)
_txtShortcut.Enabled = _ckbIsTopLevel.Checked == false && _ckbSubMenu.Checked == false;
}
};
- _ckbNullCheck.Toggled += (s,e) => {
+ _ckbNullCheck.Toggled += (s, e) => {
if (_menuItem != null) {
_menuItem.AllowNullChecked = (bool)_ckbNullCheck.Checked;
}
@@ -861,7 +861,7 @@ public DynamicMenuItem EnterMenuItem ()
var _btnOk = new Button ("Ok") {
IsDefault = true,
};
- _btnOk.Clicked += (s,e) => {
+ _btnOk.Clicked += (s, e) => {
if (ustring.IsNullOrEmpty (_txtTitle.Text)) {
MessageBox.ErrorQuery ("Invalid title", "Must enter a valid title!.", "Ok");
} else {
@@ -870,7 +870,7 @@ public DynamicMenuItem EnterMenuItem ()
}
};
var _btnCancel = new Button ("Cancel");
- _btnCancel.Clicked += (s,e) => {
+ _btnCancel.Clicked += (s, e) => {
_txtTitle.Text = ustring.Empty;
Application.RequestStop ();
};
diff --git a/UICatalog/Scenarios/Text.cs b/UICatalog/Scenarios/Text.cs
index ae357912c8..9e905b55a4 100644
--- a/UICatalog/Scenarios/Text.cs
+++ b/UICatalog/Scenarios/Text.cs
@@ -21,6 +21,7 @@ public override void Setup ()
X = 1,
Y = 0,
Width = Dim.Percent (50) - 1,
+ // Height will be replaced with 1
Height = 2
};
@@ -51,7 +52,7 @@ void TextField_TextChanging (object sender, TextChangingEventArgs e)
// TextView is a rich (as in functionality, not formatting) text editing control
var textView = new TextView () {
X = 1,
- Y = Pos.Bottom (textField),
+ Y = Pos.Bottom (textField) + 1,
Width = Dim.Percent (50) - 1,
Height = Dim.Percent (30),
};
diff --git a/UICatalog/UICatalog.cs b/UICatalog/UICatalog.cs
index f3ca107bb8..9ef655d5ee 100644
--- a/UICatalog/UICatalog.cs
+++ b/UICatalog/UICatalog.cs
@@ -250,6 +250,7 @@ static Scenario RunUICatalogTopLevel ()
/// the command line) and each time a Scenario ends.
///
public class UICatalogTopLevel : Toplevel {
+ public MenuItem? miUseSubMenusSingleFrame;
public MenuItem? miIsMenuBorderDisabled;
public MenuItem? miIsMouseDisabled;
public MenuItem? miEnableConsoleScrolling;
@@ -491,18 +492,36 @@ List