Author Topic: UIInput Trap (or eat) keys when control has focus?  (Read 4012 times)

OnResolve

  • Guest
UIInput Trap (or eat) keys when control has focus?
« 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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput Trap (or eat) keys when control has focus?
« Reply #1 on: April 12, 2013, 05:52:36 PM »
If you are handing Input directly, you need to check UICamera.inputHasFocus.

OnResolve

  • Guest
Re: UIInput Trap (or eat) keys when control has focus?
« Reply #2 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.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput Trap (or eat) keys when control has focus?
« Reply #3 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.