Skip to content

Commit 6382336

Browse files
committed
fix comments
1 parent 4da479f commit 6382336

File tree

1 file changed

+7
-10
lines changed
  • src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips

1 file changed

+7
-10
lines changed

src/System.Windows.Forms/System/Windows/Forms/Controls/ToolStrips/ToolStrip.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4578,10 +4578,11 @@ protected override void WndProc(ref Message m)
45784578
{
45794579
SnapFocus((HWND)(nint)m.WParamInternal);
45804580

4581-
// For fix https://github.com/dotnet/winforms/issues/12916
4582-
// Narrow down the range, because ToolStripDropDown is ToolStrip too. we only need to set outer ToolStrip active.
4581+
// For fix https://github.com/dotnet/winforms/issues/13400
4582+
// Narrow down the range because TransparentToolStrip (at design time) is also a ToolStrip. We only need to set the outer ToolStrip as active.
45834583
if (IsOuterToolStrip(this))
45844584
{
4585+
// For fix https://github.com/dotnet/winforms/issues/12916
45854586
ToolStripManager.ModalMenuFilter.SetActiveToolStrip(this);
45864587
}
45874588
}
@@ -4653,17 +4654,13 @@ protected override void WndProc(ref Message m)
46534654

46544655
static bool IsOuterToolStrip(ToolStrip toolStrip)
46554656
{
4656-
static ToolStrip getParentToolStrip(ToolStrip toolStrip)
4657+
ToolStrip tempToolStrip = toolStrip;
4658+
while (tempToolStrip.Parent is ToolStrip parentControl)
46574659
{
4658-
if (toolStrip.Parent is ToolStrip parent)
4659-
{
4660-
return getParentToolStrip(parent);
4661-
}
4662-
4663-
return toolStrip;
4660+
tempToolStrip = parentControl;
46644661
}
46654662

4666-
return toolStrip == getParentToolStrip(toolStrip);
4663+
return toolStrip == tempToolStrip;
46674664
}
46684665
}
46694666

0 commit comments

Comments
 (0)