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

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;
}
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>

View File

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

View File

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

View File

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

View File

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

View File

@ -213,7 +213,7 @@ namespace Sunny.UI
public void Translate()
{
List<Control> controls = this.GetTranslateControls("ITranslate");
List<Control> controls = this.GetInterfaceControls("ITranslate");
foreach (var control in controls)
{
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)
{
if (FormBorderStyle == FormBorderStyle.None && ShowTitle)

View File

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

View File

@ -537,7 +537,7 @@ namespace Sunny.UI
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>();
@ -550,7 +550,7 @@ namespace Sunny.UI
if (obj.Controls.Count > 0)
{
values.AddRange(obj.GetTranslateControls(interfaceName));
values.AddRange(obj.GetInterfaceControls(interfaceName));
}
}