Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: pdelaossa on November 20, 2014, 03:01:46 AM

Title: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: pdelaossa on November 20, 2014, 03:01:46 AM
We are having 2 problems related to UIInput in Windows Store compilations. I checked that these happen in both desktop, arm and x86 tablets (Surface and Surface Pro). We're updated to 3.7.6.

1st problem)
The keyboard doesn't open. I saw that you already call mKeyboard.active = true on Update when MOBILE is defined.
MOBILE directive is, however, not defined when we are in UNITY_METRO.
We were able to hack that problem adding (mKey = keyboard.Open(null); mKey.active=true; ) to OnPress.
But this is not a solution, and the behaviour is not the intended.
In Windows Store desktop there's no touch keyboard, so obviously it doesn't show up.

2nd problem)
The backspace doesn't work. The directional keys don't work neither, but those we don't use.
We tried tracking the methods up to DoBackspace->Insert("") and found that they are not even called in Windows Store compilations.
Neither desktop or tablet compilations detect backspace.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: brunoroma on November 20, 2014, 11:31:04 AM
+1 :( WIN PHONE 8.1 last NGUI UNITY 4.5.5.p5
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: Nerosam on November 20, 2014, 05:49:47 PM
+1 on this as it seems related to an issue I posted about earlier (in a different thread) in a video demonstration.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: ArenMook on November 20, 2014, 09:23:59 PM
Hack that file to your heart's content. Modify whichever defines you need. I'll be honest -- I am sick and tired of hacking it. There are dozens upon dozens of hacks inside already, all done because of Unity's utterly shitty input support. Every platform supported by Unity has some platform-specific issues / glitches / bugs / absurdities. I've mentioned it countless times on this forum. Worse yet, different versions of Unity often break things that worked before.

So to sum it up: Unity's input support is shit, especially on WP8/WSA.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: brunoroma on November 21, 2014, 01:57:01 AM
ok.. so the solution? or we have to leave NGUI vs uGUI?

is a money question I have game ready for WINPHONE 8.1 and no possibility to publish. The keyboard appears once for one second then disappears for ever :-[
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on November 21, 2014, 06:03:45 AM
I have the exact same problem here :/


Do you have something you can point us to? Like what part of the code we need to update or look at?
The thing is that TouchScreenKeyboard is not usable on a build for Standalone, so what are you using instead to display the keyboard?


I'll try to spend 1-2 day on this to have a fix, but don't really know where to start or even what method to call to show the keyboard on this platform (Surface Pro 2).

Thanks!
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: ArenMook on November 21, 2014, 08:58:51 PM
Touch screen keyboard is opened in UIInput's Update() function on line 641. If there is a problem, that's where it will be. Log the events that occur, check to see which ones you get and in which order -- does OnPress get sent twice, perhaps? Once for mouse once for touch? That's usually the case with Unity, as they deemed it necessary to send both from the same action with no way to differentiate between real mouse events and the fake ones. Everything you need is in UIInput.Update().
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on November 24, 2014, 03:00:56 AM
Will try to look into that, but there is a lot of code and I don't know what is the correct following of events etc...
Also hard to work directly on the SP2 that is really slow etc...

I'll let you know!
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: pdelaossa on November 24, 2014, 07:14:35 AM
As I posted in OP, there's an easy hack that forces the keyboard to show up each time you click on the UIInput.

We force the keyboard to open directly in OnPress. This is the method Arenmook is using for the caret positioning/selection handling.

This means, adding the following code to OnPress (posting the whole method goes against the rules, but it is a small one):
  1. #if UNITY_METRO
  2.       var key = TouchScreenKeyboard.Open(null); // null is also not what we need here, but as a hack it is good enough
  3.       key.active = true;
  4. #endif

But showing the keyboard is only the first of the problems!

The second problem, which I wasn't able to bypass, is that the UIInput themselves don't receive the "Backspace" or "Arrow key"s key inputs.
Therefore, it is impossible to remove things you have written.

Anyone got any idea? I will try tracing back the events again, but from my first try:
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: Nerosam on November 24, 2014, 01:19:13 PM
I'm currently in the process of switching UIInput with uGUI's "InputField" components. I needed to download the latest Unity 4.6 Beta for this but so far, the input implementation is working perfectly. I just have a Canvas object with the 3D world space option enabled on the same GameObject as the UIRoot script

I attempted to fix UIInput.cs for Windows Store Universal Myself but my efforts ended up being in vain. One fix would break something else.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: Nerosam on November 27, 2014, 12:14:34 PM
It seems Unity 4.6 fixed the keyboard issue I was having with the keyboard on WP8 onthe UIInput script
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on November 27, 2014, 12:20:22 PM
Hello.
You mean that using Unity 4.6 with the current version of NGUI works?


Thanks :)
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: Nerosam on November 27, 2014, 01:46:20 PM
Im currently on version 3.7.0 but things seem to be working for me on 4.6. Havnt fully tested though.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on November 30, 2014, 06:13:19 AM
Thanks.

Will try when I can!
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on December 01, 2014, 09:10:42 AM
Same thing for me using 4.6.
Absolutely not showing the keyboard on a Surface Pro device :(
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: pdelaossa on December 02, 2014, 02:44:43 AM
Same thing for me using 4.6.
Absolutely not showing the keyboard on a Surface Pro device :(

I already posted a hack in this very same thread, less than 10 posts behind.

The problem that is still not solved (or hacked) is that Backspace and arrow keys don't work.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: ArenMook on December 02, 2014, 12:18:10 PM
I am pretty sure if you don't check "hide input" it should all work as expected. There are a lot of hacks that go into hiding input on mobile/metro devices.

I don't quite understand your hack, pdelaossa. 'mKeyboard' should already exist at that point, so why do you re-open it, and with null of all things? Would simply changing OnPress to this work?:
  1.         protected virtual void OnPress (bool isPressed)
  2.         {
  3.                 if (isPressed && isSelected && label != null &&
  4.                         (UICamera.currentScheme == UICamera.ControlScheme.Mouse ||
  5.                          UICamera.currentScheme == UICamera.ControlScheme.Touch))
  6.                 {
  7.  #if UNITY_METRO
  8.                         if (mKeyboard != null) mKeyboard.active = true;
  9.  #endif
  10.                         selectionEnd = GetCharUnderMouse();
  11.                         if (!Input.GetKey(KeyCode.LeftShift) &&
  12.                                 !Input.GetKey(KeyCode.RightShift)) selectionStart = mSelectionEnd;
  13.                 }
  14.         }
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on December 03, 2014, 12:01:14 PM
Hey pdelaossa,


Your hack absolutely does not work on a Surface Pro.
With the Surface Pro, there is just no possible use of the TouchScreenKeyboard (it seems). I've tried TouchScreenKeyboard.isSupported with Unity 4.6 and it returns false on a Surface Pro... that means what it means right? Not touchscreen support from Unity on this device.


Did your hack really work on a Surface Pro? The keyboard really show up?


Also #if UNITY_METRO does not work on the SurfacePro...
Are you building with Standalone?
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: dttngan91 on December 23, 2014, 08:13:10 PM
I have the same issue on Android devices. It doesn't show up keyboard sometimes I press (onPress called), just display the carpet. :(
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: ArenMook on December 24, 2014, 07:08:28 AM
I don't recommend using the 'hide input' feature for the time being.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on December 30, 2014, 07:02:51 AM
Hi again,


I'm debugging things right now.
The solution I will use (and is working with Unity new UI) only need one thing, it's the focus on the input field. I will show the virtual keyboard myself.


The thing is... the focus is not working when I touch the screen with my finger (but is working with the mouse). I'm trying to understand why but I have some difficulties.



I'm down to the UICamera.cs script, in the coroutine ChangeSelection.


Do you have any idea of what is causing this?
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on December 30, 2014, 08:26:32 AM
Found the issue to gain focus!


It's in your coroutine ChangeSelection, I don't why, but it's the fact that you're doing "yield return new WaitForEndOfFrame();", by removing this, I have the focus and everything is working.
I just need to add a bit of custom code to launch the virtual keyboard on the Surface Pro, that is:
  1. System.Diagnostics.Process keyboardProcess = new System.Diagnostics.Process();
  2. keyboardProcess.StartInfo = new System.Diagnostics.ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe");
  3. keyboardProcess.Start();


And because I have the focus, everything is working fine, typing, selecting, deleting text etc...
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: ArenMook on December 30, 2014, 02:41:56 PM
That's strange. What if you change it to be "yield return null;" instead?
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on January 07, 2015, 05:54:55 AM
That's strange. What if you change it to be "yield return null;" instead?


Changing it to yield return null does not work.
What I've done is comment yield return new WaitForEndOfFrame and I call yield return null at the very end of the method.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: ArenMook on January 07, 2015, 01:27:16 PM
Alright, I'll make the changes, thanks.
Title: Re: UIInput still not bringing up keyboard on Windows Store. Backspace not working.
Post by: nah0y on January 07, 2015, 07:16:37 PM
No problem,
But just for info, it's not with the platform WP8 or something like that.
It's really just a Standalone Windows build, so no #if UNITY_WP8 or UNITY_METRO etc... :)