Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: huangweicong on September 13, 2012, 08:38:29 PM
-
hi, I am new here.
I want to catch the event for showing and hiding keyboard, but I didn't find any API in UIInput.
Now I used a MonoBehaviour to override the OnSelect function which represent event for showing keyboard and new a onSubmit to catch the event for hiding keyboard.
But it didn't work perfectly. When I tapped the close button on the keyboard, I cannot catch the event.
Are there any better solutions?
By the way, how can I set the attribute hideInput to the TouchScreenKeyboard, also, I didnt find any API.
Thanks
-
NGUI looks for the user to press on a text input box (I don't know the proper name, haven't used it yet) and then it calls the Unity API for opening the keyboard.
Have you seen the code in UIInput.cs at line ~200 to ~250, that deals with opening the keyboard when the input box is pressed and what to do if it's deselected (which may happen when the user dismisses the keyboard)
-
Thanks for prompt reply.
Yes, I have seen the codes. And it works well on opening keyboard. But there is a problem when closing keyboard.
When I tap done button to finish tapping, it works well because the script uses the delegate onSubmit in line 291. But when I tap close button to close keyboard, it doesn't work.
I don't know how to catch this event, and does it also use OnSelect function whenever I close the keyboard?
And how can I set the mKeyboard to hideInput? any function I can use?
Thanks
-
I have tested the script, it seems like that when I lost focus on the keyboard, it will call OnSelect function, but meanwhile, the keyboard are not necessarily closed.
-
I'm a bit confused. How do you close an on-screen keyboard without submitting it? What is the close button you mentioned? Do you know what event is sent out when that happens?
-
Maybe he means the back button, as you would find it on Android devices? Tapping that will dismiss the keyboard (on my Samsung Galaxy phone, anyway) without submitting anything to the text field.
-
the close button is in the right-bottom of the keyboard, when you tapped it, nothing happened but closed the keyboard
-
Bottom-right button for me is the return key.
-
iOS keyboard has a button to close the keyboard that is not triggering a submit in NGUI. Maybe it's just on iPad, but here's an example, bottom right key:
http://www.maclife.com/files/u12635/reminders_1.png (http://www.maclife.com/files/u12635/reminders_1.png)
-
Ah, interesting, thanks for the pic. What event is sent out when it's pressed, do you know?
-
Hmm... i'm still seeing this exact problem - was it ever solved?
thanks...
-
Unity's handling of keyboards seems different on Android vs iOS. On Android all methods of closing the keyboard trigger a submit event. NGUI checks keyboard.wasCanceled (which is never true on Android), and does a Submit() if it wasn't cancelled. If it was cancelled, then NGUI simply removes the focus from the input field which results in an OnSelect(false) message being sent.
-
I'm using NGUI 2.6.3.
for fix this problem,
in void Update()
in UIInput.cs
if (mKeyboard.done)
↓
if (mKeyboard.done || !mKeyboard.active)
What do you think?
-
So Unity doesn't set 'done' in some cases?
-
I tried pushing [hide]button(right-bottom) in iPad keyboard.
then, mKeyboard.done is false and mKeyboard.active is false.
it may be unity's bug.
but, it is in newest Unity(4.3.4f1).
-
i have same bug, if i press Hide keyboard button , then i try to tap on input field for invoke keyboard but nothing happens, that means if i have closed keyboard, i can't invoke(open) keyboard by tap on inputfield, need to reopen (disable/enable) GameObject with UIInput.
-
I've added the active check to the current version of NGUI, so you will see it in the next update.
-
We are using UIInput script in NGUI 3.9.0 to allow our user to type in our iOS app.
Is there a way to know if the user chose to Hide the keyboard(using the button at the bottom right of the digital keyboard) or chose to press the Done button?
-
One should call submit, the other simply close the keyboard. If there is no distinction on iOS, then it would be a question for Unity as there is certainly a distinction on Android.