mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
Dynamic menu/statusbar and Enable property fix. (#1489)
* Fixes both dynamic menu and status bar broken scenarios. * Fix a bug where the subviews oldEnabled can be overridden, even the superview Enable property hasn't changed.
This commit is contained in:
@@ -2154,15 +2154,16 @@ namespace Terminal.Gui {
|
||||
}
|
||||
OnEnabledChanged ();
|
||||
SetNeedsDisplay ();
|
||||
}
|
||||
if (subviews != null) {
|
||||
foreach (var view in subviews) {
|
||||
if (!value) {
|
||||
view.oldEnabled = view.Enabled;
|
||||
view.Enabled = value;
|
||||
} else {
|
||||
view.Enabled = view.oldEnabled;
|
||||
view.addingView = false;
|
||||
|
||||
if (subviews != null) {
|
||||
foreach (var view in subviews) {
|
||||
if (!value) {
|
||||
view.oldEnabled = view.Enabled;
|
||||
view.Enabled = value;
|
||||
} else {
|
||||
view.Enabled = view.oldEnabled;
|
||||
view.addingView = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ namespace UICatalog {
|
||||
[ScenarioMetadata (Name: "Dynamic MenuBar", Description: "Demonstrates how to add and remove a MenuBar, Menus and change titles dynamically.")]
|
||||
[ScenarioCategory ("Dynamic")]
|
||||
class DynamicMenuBar : Scenario {
|
||||
public override void Run ()
|
||||
public override void Init (Toplevel top, ColorScheme colorScheme)
|
||||
{
|
||||
Top.Add (new DynamicMenuBarSample (Win.Title));
|
||||
base.Run ();
|
||||
Application.Init ();
|
||||
Top = Application.Top;
|
||||
Top.Add (new DynamicMenuBarSample ($"CTRL-Q to Close - Scenario: {GetName ()}"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@ namespace UICatalog {
|
||||
[ScenarioMetadata (Name: "Dynamic StatusBar", Description: "Demonstrates how to add and remove a StatusBar and change items dynamically.")]
|
||||
[ScenarioCategory ("Dynamic")]
|
||||
class DynamicStatusBar : Scenario {
|
||||
public override void Run ()
|
||||
public override void Init (Toplevel top, ColorScheme colorScheme)
|
||||
{
|
||||
Top.Add (new DynamicStatusBarSample (Win.Title));
|
||||
base.Run ();
|
||||
Application.Init ();
|
||||
Top = Application.Top;
|
||||
Top.Add (new DynamicStatusBarSample ($"CTRL-Q to Close - Scenario: {GetName ()}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,6 +223,7 @@ namespace UICatalog {
|
||||
_statusBar.AddItemAt (_currentSelectedStatusBar, newStatusItem);
|
||||
DataContext.Items.Add (new DynamicStatusItemList (newStatusItem.Title, newStatusItem));
|
||||
_lstItems.MoveDown ();
|
||||
SetFrameDetails ();
|
||||
};
|
||||
|
||||
_btnRemove.Clicked += () => {
|
||||
@@ -310,8 +312,7 @@ namespace UICatalog {
|
||||
|
||||
StatusItem CreateNewStatusBar (DynamicStatusItem item)
|
||||
{
|
||||
StatusItem newStatusItem;
|
||||
newStatusItem = new StatusItem (ShortcutHelper.GetShortcutFromTag (
|
||||
var newStatusItem = new StatusItem (ShortcutHelper.GetShortcutFromTag (
|
||||
item.shortcut, StatusBar.ShortcutDelimiter),
|
||||
item.title, _frmStatusBarDetails.CreateAction (item));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user