Added extra event on the AutoCompleteComboBox, to fire when an item in the list is selected, with its display name

Resolves: https://github.com/Unity-UI-Extensions/com.unity.uiextensions/issues/200
pull/460/head
SimonDarksideJ 2023-11-26 15:26:11 +00:00
parent a47d694796
commit b171b2c1c2
1 changed files with 6 additions and 1 deletions

View File

@ -131,6 +131,9 @@ namespace UnityEngine.UI.Extensions
[System.Serializable]
public class SelectionValidityChangedEvent : Events.UnityEvent<bool> { }
[System.Serializable]
public class ItemSelectedEvent : Events.UnityEvent<string> { }
[System.Serializable]
public class ControlDisabledEvent : Events.UnityEvent<bool> { }
@ -141,6 +144,8 @@ namespace UnityEngine.UI.Extensions
public SelectionValidityChangedEvent OnSelectionValidityChanged;
// fires in both cases
public SelectionChangedEvent OnSelectionChanged;
// fires when an item is clicked
public ItemSelectedEvent OnItemSelected;
// fires when item is changed;
public ControlDisabledEvent OnControlDisabled;
@ -358,10 +363,10 @@ namespace UnityEngine.UI.Extensions
/// <param name="item"></param>
private void OnItemClicked(string item)
{
//Debug.Log("item " + item + " clicked");
Text = item;
_mainInput.text = Text;
ToggleDropdownPanel(true);
OnItemSelected?.Invoke(Text);
}
private void RedrawPanel()