mirror of
https://github.com/peng-zhihui/ElectronBot.git
synced 2026-10-22 23:39:58 +08:00
69 lines
1.3 KiB
C#
69 lines
1.3 KiB
C#
namespace UIWidgets
|
|
{
|
|
using UIWidgets.Styles;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// PickerString.
|
|
/// </summary>
|
|
[System.Obsolete("Replaced with PickerStringV2.")]
|
|
public class PickerString : Picker<string, PickerString>
|
|
{
|
|
/// <summary>
|
|
/// ListView.
|
|
/// </summary>
|
|
[SerializeField]
|
|
public ListView ListView;
|
|
|
|
/// <summary>
|
|
/// Prepare picker to open.
|
|
/// </summary>
|
|
/// <param name="defaultValue">Default value.</param>
|
|
public override void BeforeOpen(string defaultValue)
|
|
{
|
|
ListView.SelectedIndex = ListView.DataSource.IndexOf(defaultValue);
|
|
|
|
ListView.OnSelectString.AddListener(ListViewCallback);
|
|
}
|
|
|
|
void ListViewCallback(int index, string value)
|
|
{
|
|
Selected(value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Prepare picker to close.
|
|
/// </summary>
|
|
public override void BeforeClose()
|
|
{
|
|
ListView.OnSelectString.RemoveListener(ListViewCallback);
|
|
}
|
|
|
|
#region IStylable implementation
|
|
|
|
/// <inheritdoc/>
|
|
public override bool SetStyle(Style style)
|
|
{
|
|
base.SetStyle(style);
|
|
|
|
ListView.SetStyle(style);
|
|
|
|
style.Dialog.Button.ApplyTo(transform.Find("Buttons/Cancel"));
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool GetStyle(Style style)
|
|
{
|
|
base.GetStyle(style);
|
|
|
|
ListView.GetStyle(style);
|
|
|
|
style.Dialog.Button.GetFrom(transform.Find("Buttons/Cancel"));
|
|
|
|
return true;
|
|
}
|
|
#endregion
|
|
}
|
|
} |