mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-30 09:47:58 +01:00
Implementing UseSubMenusSingleFrame in context menu.
This commit is contained in:
@@ -106,7 +106,8 @@ namespace Terminal.Gui {
|
||||
X = position.X,
|
||||
Y = position.Y,
|
||||
Width = 0,
|
||||
Height = 0
|
||||
Height = 0,
|
||||
UseSubMenusSingleFrame = UseSubMenusSingleFrame
|
||||
};
|
||||
|
||||
menuBar.isContextMenuLoading = true;
|
||||
@@ -201,5 +202,10 @@ namespace Terminal.Gui {
|
||||
/// Gets the <see cref="Gui.MenuBar"/> that is hosting this context menu.
|
||||
/// </summary>
|
||||
public MenuBar MenuBar { get => menuBar; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets if the sub-menus must be displayed in a single or multiple frames.
|
||||
/// </summary>
|
||||
public bool UseSubMenusSingleFrame { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -757,8 +757,10 @@ namespace Terminal.Gui {
|
||||
if (item == null || !item.IsEnabled ()) disabled = true;
|
||||
if (item != null && !disabled)
|
||||
current = me.Y - 1;
|
||||
if (host.UseSubMenusSingleFrame || !CheckSubMenu ())
|
||||
if (host.UseSubMenusSingleFrame || !CheckSubMenu ()) {
|
||||
SetNeedsDisplay ();
|
||||
return true;
|
||||
}
|
||||
host.OnMenuOpened ();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,19 @@ namespace UICatalog.Scenarios {
|
||||
private MenuItem miForceMinimumPosToZero;
|
||||
private bool forceMinimumPosToZero = true;
|
||||
private TextField tfTopLeft, tfTopRight, tfMiddle, tfBottomLeft, tfBottomRight;
|
||||
private MenuItem miUseSubMenusSingleFrame;
|
||||
private bool useSubMenusSingleFrame;
|
||||
|
||||
public override void Setup ()
|
||||
{
|
||||
var text = "Context Menu";
|
||||
var width = 20;
|
||||
|
||||
Win.Add (new Label ("Press 'Ctrl + Space' to open the Window context menu.") {
|
||||
X = Pos.Center (),
|
||||
Y = 1
|
||||
});
|
||||
|
||||
tfTopLeft = new TextField (text) {
|
||||
Width = width
|
||||
};
|
||||
@@ -89,10 +96,14 @@ namespace UICatalog.Scenarios {
|
||||
tfBottomLeft.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero;
|
||||
tfBottomRight.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero;
|
||||
}) { CheckType = MenuItemCheckStyle.Checked, Checked = forceMinimumPosToZero },
|
||||
miUseSubMenusSingleFrame = new MenuItem ("Use_SubMenusSingleFrame", "",
|
||||
() => contextMenu.UseSubMenusSingleFrame = miUseSubMenusSingleFrame.Checked = useSubMenusSingleFrame = !useSubMenusSingleFrame) {
|
||||
CheckType = MenuItemCheckStyle.Checked, Checked = useSubMenusSingleFrame
|
||||
},
|
||||
null,
|
||||
new MenuItem ("_Quit", "", () => Application.RequestStop ())
|
||||
})
|
||||
) { ForceMinimumPosToZero = forceMinimumPosToZero };
|
||||
) { ForceMinimumPosToZero = forceMinimumPosToZero, UseSubMenusSingleFrame = useSubMenusSingleFrame };
|
||||
|
||||
tfTopLeft.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero;
|
||||
tfTopRight.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero;
|
||||
|
||||
Reference in New Issue
Block a user