From ce2c7cb55aa59a4b89dd2a055d2370bb0f6d5180 Mon Sep 17 00:00:00 2001 From: Sunny Date: Fri, 10 Feb 2023 21:21:08 +0800 Subject: [PATCH] =?UTF-8?q?*=20UINavMenu:=20=E6=9C=89=E5=AD=90=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E6=97=B6=EF=BC=8C=E9=BC=A0=E6=A0=87=E5=B7=A6=E9=94=AE?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E7=88=B6=E7=BA=A7=E7=82=B9=E5=B1=95=E5=BC=80?= =?UTF-8?q?/=E6=94=B6=E7=BC=A9=EF=BC=8C=E5=8F=B3=E9=94=AE=E9=80=89?= =?UTF-8?q?=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SunnyUI/Controls/UINavMenu.cs | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/SunnyUI/Controls/UINavMenu.cs b/SunnyUI/Controls/UINavMenu.cs index 79ace9f0..9d59ec0d 100644 --- a/SunnyUI/Controls/UINavMenu.cs +++ b/SunnyUI/Controls/UINavMenu.cs @@ -32,6 +32,7 @@ * 2022-11-03: V3.2.6 增加了可设置垂直滚动条宽度的属性 * 2022-11-03: V3.2.6 重写了节点右侧图标的绘制 * 2023-02-02: V3.3.1 修复了鼠标离开事件 +* 2023-02-10: V3.3.2 有子节点时,鼠标左键点击父级点展开/收缩,右键选中 ******************************************************************************/ using System; @@ -854,20 +855,28 @@ namespace Sunny.UI { if (e.Node.Nodes.Count > 0) { - if (e.Node.IsExpanded) + if (e.Button == MouseButtons.Left) { - e.Node.Collapse(); - } - else - { - e.Node.Expand(); + if (e.Node.IsExpanded) + { + e.Node.Collapse(); + } + else + { + e.Node.Expand(); + } + + if (SelectedNode != null && SelectedNode == e.Node && e.Node.IsExpanded && ExpandSelectFirst && e.Node.Nodes.Count > 0) + { + SelectedNode = e.Node.Nodes[0]; + } + else + { + SelectedNode = e.Node; + } } - if (SelectedNode != null && SelectedNode == e.Node && e.Node.IsExpanded && ExpandSelectFirst && e.Node.Nodes.Count > 0) - { - SelectedNode = e.Node.Nodes[0]; - } - else + if (e.Button == MouseButtons.Right) { SelectedNode = e.Node; }