* UITextBox:增加FocusedSelectAll属性,激活时全选。
This commit is contained in:
parent
866cbcd2c5
commit
979b7b5c09
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
BIN
Bin/SunnyUI.pdb
BIN
Bin/SunnyUI.pdb
Binary file not shown.
Binary file not shown.
@ -478,9 +478,20 @@ namespace Sunny.UI
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
if (FocusedSelectAll)
|
||||
{
|
||||
SelectAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectionStart = Text.Length;
|
||||
SelectionLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
public bool FocusedSelectAll { get; set; }
|
||||
|
||||
protected override void OnLeave(EventArgs e)
|
||||
{
|
||||
|
@ -83,6 +83,14 @@ namespace Sunny.UI
|
||||
Leave?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Description("激活时选中全部文字"), Category("SunnyUI")]
|
||||
public bool FocusedSelectAll
|
||||
{
|
||||
get => edit.FocusedSelectAll;
|
||||
set => edit.FocusedSelectAll = value;
|
||||
}
|
||||
|
||||
private void UITextBox_TextAlignmentChange(object sender, ContentAlignment alignment)
|
||||
{
|
||||
if (edit == null) return;
|
||||
@ -129,6 +137,10 @@ namespace Sunny.UI
|
||||
private void Edit_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
Cursor = editCursor;
|
||||
if (FocusedSelectAll)
|
||||
{
|
||||
SelectAll();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseWheel(object sender, MouseEventArgs e)
|
||||
@ -191,6 +203,7 @@ namespace Sunny.UI
|
||||
|
||||
public void Select(int start, int length)
|
||||
{
|
||||
edit.Focus();
|
||||
edit.Select(start, length);
|
||||
}
|
||||
|
||||
@ -231,6 +244,7 @@ namespace Sunny.UI
|
||||
|
||||
public void SelectAll()
|
||||
{
|
||||
edit.Focus();
|
||||
edit.SelectAll();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user