* 内置的一些容器增加关闭过滤下拉框的点击事件

This commit is contained in:
Sunny 2023-03-26 22:06:43 +08:00
parent 9b3e30d54a
commit bc66440c97
8 changed files with 40 additions and 5 deletions

View File

@ -386,6 +386,18 @@ namespace Sunny.UI
return list; return list;
} }
internal static void HideComboDropDown(this Control ctrl)
{
var ctrls = ctrl.RootForm().GetInterfaceControls("IHideDropDown", true);
foreach (var control in ctrls)
{
if (control is IHideDropDown item)
{
item.HideDropDown();
}
}
}
/// <summary> /// <summary>
/// 查找包含接口名称的控件列表 /// 查找包含接口名称的控件列表
/// </summary> /// </summary>

View File

@ -53,7 +53,7 @@ namespace Sunny.UI
[DefaultEvent("SelectedIndexChanged")] [DefaultEvent("SelectedIndexChanged")]
[ToolboxItem(true)] [ToolboxItem(true)]
[LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")] [LookupBindingProperties("DataSource", "DisplayMember", "ValueMember", "SelectedValue")]
public sealed partial class UIComboBox : UIDropControl, IToolTip public sealed partial class UIComboBox : UIDropControl, IToolTip, IHideDropDown
{ {
/// <summary> /// <summary>
/// 构造函数 /// 构造函数

View File

@ -40,6 +40,11 @@ namespace Sunny.UI
public const int EditorMaxHeight = 60; public const int EditorMaxHeight = 60;
} }
public interface IHideDropDown
{
public void HideDropDown();
}
public class UIDateTimeArgs : EventArgs public class UIDateTimeArgs : EventArgs
{ {
public DateTime DateTime { get; set; } public DateTime DateTime { get; set; }

View File

@ -29,7 +29,7 @@ namespace Sunny.UI
{ {
[ToolboxItem(true)] [ToolboxItem(true)]
[DefaultEvent("ValueChanged")] [DefaultEvent("ValueChanged")]
public class UINumPadTextBox : UIDropControl, IToolTip public class UINumPadTextBox : UIDropControl, IToolTip, IHideDropDown
{ {
public UINumPadTextBox() public UINumPadTextBox()
{ {

View File

@ -50,6 +50,12 @@ namespace Sunny.UI
SetStyleFlags(true, false); SetStyleFlags(true, false);
} }
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
this.HideComboDropDown();
}
[Browsable(false)] [Browsable(false)]
public bool Disabled => !Enabled; public bool Disabled => !Enabled;

View File

@ -213,7 +213,7 @@ namespace Sunny.UI
public void Translate() public void Translate()
{ {
List<Control> controls = this.GetTranslateControls("ITranslate"); List<Control> controls = this.GetInterfaceControls("ITranslate");
foreach (var control in controls) foreach (var control in controls)
{ {
if (control is ITranslate item) if (control is ITranslate item)
@ -685,6 +685,12 @@ namespace Sunny.UI
} }
} }
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
this.HideComboDropDown();
}
protected override void OnMouseClick(MouseEventArgs e) protected override void OnMouseClick(MouseEventArgs e)
{ {
if (FormBorderStyle == FormBorderStyle.None && ShowTitle) if (FormBorderStyle == FormBorderStyle.None && ShowTitle)

View File

@ -110,6 +110,12 @@ namespace Sunny.UI
base.SizeGripStyle = SizeGripStyle.Hide; base.SizeGripStyle = SizeGripStyle.Hide;
} }
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
this.HideComboDropDown();
}
public event PageDeselectingEventHandler PageDeselecting; public event PageDeselectingEventHandler PageDeselecting;
internal bool OnPageDeselecting() internal bool OnPageDeselecting()

View File

@ -537,7 +537,7 @@ namespace Sunny.UI
return values; return values;
} }
public static List<Control> GetTranslateControls(this Control ctrl, string interfaceName) public static List<Control> GetInterfaceControls(this Control ctrl, string interfaceName)
{ {
List<Control> values = new List<Control>(); List<Control> values = new List<Control>();
@ -550,7 +550,7 @@ namespace Sunny.UI
if (obj.Controls.Count > 0) if (obj.Controls.Count > 0)
{ {
values.AddRange(obj.GetTranslateControls(interfaceName)); values.AddRange(obj.GetInterfaceControls(interfaceName));
} }
} }