Author Topic: On Screen Keyboard  (Read 2517 times)

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
On Screen Keyboard
« on: May 15, 2014, 09:59:44 AM »
I'm attempting to implement an on screen keyboard capable of leveraging NGUIs UIInput. Since NGUI uses the Unity Input class directly, it's difficult to send fake presses through SendMessage or reflection like I was hoping. It seems I'll have to fool Unity itself into handling keyboard events that I create in code.

Anyone have any clever ideas how I would go about doing that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: On Screen Keyboard
« Reply #1 on: May 15, 2014, 12:06:55 PM »
UIInput actually uses OnGUI for processing of character events, not Input. Why are you implementing your own on-screen keyboard anyway?

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
Re: On Screen Keyboard
« Reply #2 on: May 15, 2014, 12:17:24 PM »
I'm working on a contract that requires a game on a giant touchscreen run by a Windows machine. There will be no keyboard, but there will be a leaderboard where players can enter initials. If there's a better way, I'm certainly open to ideas.

If I haven't misunderstood, UIInput reads from Input.inputString in Update() and sticks that text in the label. It also listens for Events in OnGUI and processes though, but that seems to only handle stuff like arrow keys, cut, copy, paste, etc.

My current plan is to create my own InputShim that mirrors the interface of Input and relays the calls, but allows me to insert my own stuff when I want. Then I can add

  1. using Input = InputShim;

to UIInput to utilize it, without having to start from scratch or heavily modify UIInput.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: On Screen Keyboard
« Reply #3 on: May 16, 2014, 12:26:42 PM »
Well, nothing is stopping you from having each button append a specific character to the input.value. No modifications necessary, just a tiny script that has an OnClick function and a KeyCode field you can set.

AtomicBob

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 69
    • View Profile
Re: On Screen Keyboard
« Reply #4 on: May 16, 2014, 12:29:18 PM »
True, and I should be able to use uiInput.SendMessage(ProcessEvents, myEvent) to retain advanced behavior. I may go that route. Thanks.