Support => NGUI 3 Support => Topic started by: CntrySocialite on February 27, 2014, 08:11:15 PM
Title: [Solved] UIPopupList OnChange not able to trigger UIInput.IsSelected
Post by: CntrySocialite on February 27, 2014, 08:11:15 PM
Objective - set focus to UIInput when a certain value is selected from a UIPopuplist.
Issue - UIInput OnSelect doesn't ever trigger.
Details - I'm successfully catching the OnChange event from the UIPopuplist. During the OnChange event I do a <UIInput>.IsSelected = True. I've tracked that the UICamera actually catches the SetSelection from the UIInput. The camera roles it to "mNextSelection" cuz the "mCurrentSelection" is on the UIPopuplist. Further down in UICamera.SetSelection the StartCoroutine for ChangeSelection will fire because "mNextSelected" has the UIInput in it...but then it gets lost. UIInput OnSelect doesn't fire. You can continue to watch UICamera.SetSelection and the next call wipes out both mNextSelection and mCurrentSelection....kinda like the UIPopuplist is cleaning itself up or something?!
Possible workaround - Instead of doing "<UIIInput.IsSelected = True" I can call a public OnSelect for UIInput in its place and it'll set focus to the UIInput like I'm looking for. That would mean I'd have to change OnSelect to public every time I load a new NGUI.
I'm still working on it and I'm perusing the forums but I'm starting to come up short on ideas. any thoughts?
Currently using NGUI 3.5.1. I've replicated the issue in a fresh scene with just a simple UIPopuplist and a simple UIInput.
Title: Re: UIPopupList OnChange not able to trigger UIInput.IsSelected
Post by: ArenMook on February 28, 2014, 07:39:18 PM
Start a coroutine for selection instead, and change the selection inside of it after yielding for WaitForEndOfFrame. Otherwise it will conflict with the popup list's clearing of selection.
Title: Re: [Solved] UIPopupList OnChange not able to trigger UIInput.IsSelected
Post by: CntrySocialite on February 28, 2014, 11:31:34 PM
That'll do it! much appreciated, thank you!
Title: Re: [Solved] UIPopupList OnChange not able to trigger UIInput.IsSelected
Post by: Zyxil on August 29, 2014, 11:06:41 PM
For anybody that finds this later:
Instead of going through the hassle of creating a Coroutine, just use Invoke: