Author Topic: Deselect input on disable?  (Read 1710 times)

DirtyHippy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Deselect input on disable?
« on: September 06, 2015, 09:28:36 PM »
On disable I am trying to disable an active UIInput with an override of Cleanup (called from OnDisable) on UIInput.  This, however, doesn't work (calling isSelected = false).

Is there a way to do this?  UIInput.selection remains set to the input even after it is disabled and when I re-enable the window the input is still happily focused.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Deselect input on disable?
« Reply #1 on: September 13, 2015, 04:54:48 AM »
I'd need to know more details -- the code you're using would help. Also which version of NGUI?

DirtyHippy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Deselect input on disable?
« Reply #2 on: September 15, 2015, 09:20:28 AM »
3.9.2.

The use case is pretty simple.  Make an input and select it.  Disable its parent while it is selected.  I would expect it to be automatically unselected when this happens, but it is not, since to me having something selected implies it is selectable in the first place.

Add an OnDisable and set IsSelected to false on the input.  Note that even after disabling, and then re-enabling the container gameobject, the input is still selected.

This particular case is in a tabbed dialog with a bunch of tabs with nested scroll views.  On several of the content pages are inputs (used for searching the contents of that tab), and I would like to deselect the inputs if you close the dialog (with escape) while you have them selected (or you die and I force the window closed).