Author Topic: UIInput (UICamera really) Intercepting Input  (Read 2372 times)

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
UIInput (UICamera really) Intercepting Input
« on: November 29, 2013, 05:16:21 PM »
Trying to work around the changes from 3.0.0 to 3.0.6 and somewhere in there I've realized that the UIInput now uses OnGUI to process events.

I was like, ugh, and figured I'd just use a check for the input I need during Update() but... it seems that UIInput (or UICamera really) now intercepts all input as if it were actually using OnGUI or some such thing.  It's the best I can explain it... when I had a giant OnGUI-GUI, when you selected a text field it took precedence for all of the keyboard input, 'intercepting' it from Update() or whatnot.  I'm sure you get the gist.

I am sure I can do ahead and code around it, but... ugh.  Please make ProcessEvent(Event ev) virtual so I won't have to keep changing this every update I suppose.

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput (UICamera really) Intercepting Input
« Reply #1 on: November 29, 2013, 07:27:08 PM »
It only intercepts input if it's actually selected:
  1.         void OnGUI ()
  2.         {
  3.                 if (isSelected && Event.current.rawType == EventType.KeyDown)
  4.                         ProcessEvent(Event.current);
  5.         }
...so I am not quite sure what issue it's causing you?

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: UIInput (UICamera really) Intercepting Input
« Reply #2 on: November 29, 2013, 07:49:09 PM »
Oh, I know...  I guess I just need to explain better.

Old NGUI UIInput did not use OnGUI to intercept the keyboard events.  As such, I wrote my own stuff for cycling old input (a buffer full of what you have typed previously), have it do special commands, and whatnot.  So while UIInput let me type stuff, and then pressing enter did OnSubmit(), it was easier for me to manage.

New NGUI UIInput uses OnGUI for processing the keyboard events.  When it does this, they are intercepted and my code no longer is usable.  I changed the ProcessEvent(Event ev) to virtual, and basically moved all my code to be compatible with the new method.

I was just surprised when suddenly nothing worked and I had to figure out why, then I was like... well I can just check for keyboard events still, but even with the OnGUI stuff commented it out, when the UIInput had focus, it still seemed as if it were intercepting the keyboard input.  Pretty sure, though I could be mistaken.

Anyhow, just some surprise and request to make the new ProcessEvent method virtual for future use.

I'll delve into here in a second, but where do I change the UIInput 'caret' symbol?  A straight line would work if it blinked, but it doesn't currently, and it's the same color... blinking and/or different color would be great, but whichever, I can live.

Hopefully that explains it better.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIInput (UICamera really) Intercepting Input
« Reply #3 on: November 29, 2013, 11:12:24 PM »
Input improvement with selection, blinking non-character caret and all that is a high priority item on the todo list right now, so it's coming soon -- likely in 3.0.8.

Yukichu

  • Full Member
  • ***
  • Thank You
  • -Given: 3
  • -Receive: 8
  • Posts: 101
    • View Profile
Re: UIInput (UICamera really) Intercepting Input
« Reply #4 on: November 30, 2013, 01:07:36 PM »
Awesomesauce :)