Author Topic: [Solved] UIPopupList OnChange not able to trigger UIInput.IsSelected  (Read 2996 times)

CntrySocialite

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
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.
« Last Edit: February 28, 2014, 11:32:12 PM by CntrySocialite »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIPopupList OnChange not able to trigger UIInput.IsSelected
« Reply #1 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.

CntrySocialite

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: [Solved] UIPopupList OnChange not able to trigger UIInput.IsSelected
« Reply #2 on: February 28, 2014, 11:31:34 PM »
That'll do it! much appreciated, thank you!

Zyxil

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 37
    • View Profile
Re: [Solved] UIPopupList OnChange not able to trigger UIInput.IsSelected
« Reply #3 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:

  1.     public void DragEnd()
  2.     { Invoke("SetFocus", 0.1f); }
  3.  
  4.     public void SetFocus()
  5.     { gameObject.GetComponent<UIInput>().isSelected = true; }
  6.