* UITextBox: 增加SelectionChanged事件
This commit is contained in:
parent
3afec3c581
commit
e3f550e6e9
@ -31,7 +31,7 @@ namespace Sunny.UI
|
|||||||
{
|
{
|
||||||
private UIDropDown itemForm;
|
private UIDropDown itemForm;
|
||||||
|
|
||||||
public UIToolStripDropDown(UIDropDownItem item)
|
public UIToolStripDropDown(UIDropDownItem item, bool autoClose = true)
|
||||||
{
|
{
|
||||||
itemForm = new UIDropDown(item);
|
itemForm = new UIDropDown(item);
|
||||||
itemForm.ValueChanged += ItemForm_ValueChanged;
|
itemForm.ValueChanged += ItemForm_ValueChanged;
|
||||||
@ -39,6 +39,7 @@ namespace Sunny.UI
|
|||||||
itemForm.Closed += ItemForm_Closed;
|
itemForm.Closed += ItemForm_Closed;
|
||||||
itemForm.Opened += ItemForm_Opened;
|
itemForm.Opened += ItemForm_Opened;
|
||||||
itemForm.Opening += ItemForm_Opening;
|
itemForm.Opening += ItemForm_Opening;
|
||||||
|
itemForm.AutoClose = autoClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Size ItemSize => itemForm.Size;
|
public Size ItemSize => itemForm.Size;
|
||||||
|
@ -206,6 +206,20 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public event OnSelectionChanged SelectionChanged;
|
||||||
|
|
||||||
|
protected override void OnKeyUp(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnKeyUp(e);
|
||||||
|
SelectionChanged?.Invoke(this, new UITextBoxSelectionArgs() { SelectionStart = this.SelectionStart, Text = this.Text });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseDown(e);
|
||||||
|
SelectionChanged?.Invoke(this, new UITextBoxSelectionArgs() { SelectionStart = this.SelectionStart, Text = this.Text });
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnKeyDown(KeyEventArgs e)
|
protected override void OnKeyDown(KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (!Multiline)
|
if (!Multiline)
|
||||||
|
@ -52,5 +52,14 @@ namespace Sunny.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class UITextBoxSelectionArgs : EventArgs
|
||||||
|
{
|
||||||
|
public int SelectionStart { get; set; }
|
||||||
|
|
||||||
|
public string Text { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void OnSelectionChanged(object sender, UITextBoxSelectionArgs e);
|
||||||
|
|
||||||
public delegate void OnDateTimeChanged(object sender, UIDateTimeArgs e);
|
public delegate void OnDateTimeChanged(object sender, UIDateTimeArgs e);
|
||||||
}
|
}
|
@ -35,6 +35,7 @@
|
|||||||
* 2022-04-11: V3.1.3 增加对按钮设置ToolTip
|
* 2022-04-11: V3.1.3 增加对按钮设置ToolTip
|
||||||
* 2022-06-10: V3.1.9 尺寸改变时重绘
|
* 2022-06-10: V3.1.9 尺寸改变时重绘
|
||||||
* 2022-06-23: V3.2.0 重写水印文字,解决不同背景色下泛白的问题
|
* 2022-06-23: V3.2.0 重写水印文字,解决不同背景色下泛白的问题
|
||||||
|
* 2022-07-17: V3.2.1 增加SelectionChanged事件
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -91,6 +92,7 @@ namespace Sunny.UI
|
|||||||
edit.MouseDown += Edit_MouseDown;
|
edit.MouseDown += Edit_MouseDown;
|
||||||
edit.MouseUp += Edit_MouseUp;
|
edit.MouseUp += Edit_MouseUp;
|
||||||
edit.MouseMove += Edit_MouseMove;
|
edit.MouseMove += Edit_MouseMove;
|
||||||
|
edit.SelectionChanged += Edit_SelectionChanged;
|
||||||
|
|
||||||
btn.Parent = this;
|
btn.Parent = this;
|
||||||
btn.Visible = false;
|
btn.Visible = false;
|
||||||
@ -122,6 +124,13 @@ namespace Sunny.UI
|
|||||||
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
TextAlignmentChange += UITextBox_TextAlignmentChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Edit_SelectionChanged(object sender, UITextBoxSelectionArgs e)
|
||||||
|
{
|
||||||
|
SelectionChanged?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public event OnSelectionChanged SelectionChanged;
|
||||||
|
|
||||||
public void SetButtonToolTip(ToolTip toolTip, string tipText)
|
public void SetButtonToolTip(ToolTip toolTip, string tipText)
|
||||||
{
|
{
|
||||||
toolTip.SetToolTip(btn, tipText);
|
toolTip.SetToolTip(btn, tipText);
|
||||||
|
@ -87,7 +87,7 @@ namespace Sunny.UI
|
|||||||
view.AfterLabelEdit += View_AfterLabelEdit;
|
view.AfterLabelEdit += View_AfterLabelEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal int DrawLeft(TreeNode node)
|
public int DrawLeft(TreeNode node)
|
||||||
{
|
{
|
||||||
if (view == null || node == null) return 0;
|
if (view == null || node == null) return 0;
|
||||||
return view.DrawLeft(node);
|
return view.DrawLeft(node);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user