Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: OnResolve on April 12, 2013, 10:17:58 AM

Title: UIInput Trap (or eat) keys when control has focus?
Post by: OnResolve on April 12, 2013, 10:17:58 AM
I just upgraded from free to the full version today and I'm transitioning the last of my unity built in GUI over to NGUI.

I've implemented a chat box very similar to the one in the shipped example.  My issue, however, seems to be that while I'm typing in the input, the key event propagation is not stopped and the key strokes still effect the game.

This was something that the built-in text boxes in Unity were providing for me and I'm definitely looking to get the functionality back.  Is there some documentation, or example, etc.. that someone can point me to?
Title: Re: UIInput Trap (or eat) keys when control has focus?
Post by: ArenMook on April 12, 2013, 05:52:36 PM
If you are handing Input directly, you need to check UICamera.inputHasFocus.
Title: Re: UIInput Trap (or eat) keys when control has focus?
Post by: OnResolve on April 12, 2013, 09:03:18 PM
If you are handing Input directly, you need to check UICamera.inputHasFocus.


So every place I have a keyboard input I need to check that `UICamera.inputHasFocus` is false??  That seems like a lot of duplicate code.  I know the `eatKeyPressOnTextFieldFocus` is deprecated now, but is there something equivalant so I'm not pasting:

  1. if(UICamera.inputHasFocus) {
  2.  return;
  3. }
  4.  
Title: Re: UIInput Trap (or eat) keys when control has focus?
Post by: ArenMook on April 13, 2013, 07:00:19 AM
There isn't. And furthermore, there is no way to control who gets the event first -- you, or NGUI.